2016-09-19 4 views
0

Ich verwende Geofencing für eine meiner Anwendung. Aber ich habe ein Problem darin. Meine Anwendung heißt nicht - (void) locationManager: (CLLocationManager *) manager didDetermineState: (CLRegionState) state forRegion: (CLRegion *) region wenn die Anwendung in Hintergrund Modus ist.CLLocationManager didDetermineState Methode nicht aufgerufen, wenn App im Hintergrund ist

ich überprüfen, für Hintergrundaktualisierung Flagge ON in Einstellungen ist.

Unten ist mein Code:

- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region 
    if (state == CLRegionStateInside) 
    { 
      NSLog(@"is in target region"); 
      UILocalNotification *notification = [[UILocalNotification alloc] init]; 
      notification.alertBody = @"You are IN of REGION"; 
      notification.fireDate = [NSDate date]; 
      NSTimeZone* timezone = [NSTimeZone defaultTimeZone]; 
      notification.timeZone = timezone; 
      notification.alertAction = @"Show"; 
      notification.soundName = UILocalNotificationDefaultSoundName; 
      [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 
    } 
    else 
    { 
      NSLog(@"is out of target region"); 
      UILocalNotification *notification = [[UILocalNotification alloc] init]; 
      notification.alertBody = @"You are OUT of REGION"; 
      notification.fireDate = [NSDate date]; 
      NSTimeZone* timezone = [NSTimeZone defaultTimeZone]; 
      notification.timeZone = timezone; 
      notification.alertAction = @"Show"; 
      notification.soundName = UILocalNotificationDefaultSoundName; 
      [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 
    } 
} 

CLLocationManager richtig eingestellt ist. Ich untersuche es, habe aber keine richtige Lösung für mein Problem bekommen. Kann mir jemand dabei helfen?

Danke

Antwort

0

Ich löste mein Problem. Es liegt daran, dass ich die Standortaktualisierung in Backgournd markiert habe. Here is image.

Verwandte Themen