ユーザーが特定の地域に入ったときに通知するアプリケーションを作成しようとしています。アプリケーションがアクティブなときに行いましたが、バックグラウンドで行う方法がわかりません。誰でも私を助けることができますか?
ここに私が使用したコードがあります:
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation];
if ([CLLocationManager regionMonitoringAvailable] && [CLLocationManager regionMonitoringEnabled])
{
loc = CLLocationCoordinate2DMake(30.794686, 31.012309);
alslamMosque =[[CLRegion alloc]initCircularRegionWithCenter:loc radius:10 identifier:@"alslam"];
CLLocationAccuracy acc = kCLLocationAccuracyNearestTenMeters;
[locationManager startMonitoringForRegion:alslamMosque desiredAccuracy:acc];
[locationManager startMonitoringSignificantLocationChanges];
}
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
UIAlertView *alr=[[UIAlertView alloc] initWithTitle:[NSString stringWithFormat: @"you've enterd region and you are %f meters from",dd]
message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
[alr show];
[alr release];
NSLog(@"enter region");
}