【问题标题】:CLLocationManager didDetermineState method not called when app is in Background应用程序处于后台时未调用 CLLocationManager didDetermineState 方法
【发布时间】:2017-01-26 20:46:09
【问题描述】:

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

我在设置中检查 Background app refresh 标志是否为 ON

下面是我的代码:

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

谢谢

【问题讨论】:

    标签: iphone cllocationmanager cllocation geofencing clregion


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-24
      • 2016-05-12
      • 1970-01-01
      • 2020-01-25
      • 2012-12-18
      • 2020-05-09
      • 2017-11-06
      • 1970-01-01
      相关资源
      最近更新 更多