【问题标题】:background gps updates not received on WatchOS 4WatchOS 4 未收到后台 GPS 更新
【发布时间】:2017-09-23 00:27:57
【问题描述】:

发布这个问题并附上答案,以便其他人可以找到它。

我们在商店中有一个记录活动路径的应用程序。当我们将 WatchOS 更新到第 4 版时,我们的后台 gps 更新在应用转换到后台时停止。

【问题讨论】:

    标签: watchkit watchos-4


    【解决方案1】:

    一些研究在Apple's Developer site 上发现了这个链接,表明我们需要在位置管理器中设置一个新属性。

    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
    if (@available(watchOS 4.0, *)) {
        self.locationManager.activityType = CLActivityTypeOther;
        self.locationManager.allowsBackgroundLocationUpdates = YES; // NEW!!
    }
    
    [self.locationManager startUpdatingLocation];
    

    查看标有“新!!”的行这就是允许应用再次接收后台位置更新的原因。您还需要按照链接中的说明设置属性。

    希望在暂停时接收位置更新的应用必须包括 他们应用程序中的 UIBackgroundModes 键(带有位置值) Info.plist 文件并将此属性的值设置为 YES。这 具有位置值的 UIBackgroundModes 键的存在是 需要后台更新

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-20
      • 1970-01-01
      • 1970-01-01
      • 2012-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多