0

我正在为我的一个应用程序使用地理围栏。但我有一个问题。当应用程序处于后台模式时,未调用我的应用程序- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region 。

我在设置中检查后台应用程序刷新标志是否打开

下面是我的代码:

- (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设置正确。我对此进行了研究,但没有为我的问题得到适当的解决方案。任何人都可以帮助我吗?

谢谢

4

1 回答 1

0

我解决了我的问题。这是因为我在背景中标记了位置更新。这是图像。

于 2017-07-21T04:19:25.497 回答