UIBackgroundModes location and significant location changes with region monitoring

后端 未结 2 1314
甜味超标
甜味超标 2020-12-25 15:14

I have an app that uses a combination of startMonitoringForRegion: and startMonitoringSignificantLocationChanges to keep aware of where the user is

相关标签:
2条回答
  • 2020-12-25 15:44

    Yes, you must need to add "location" key under Backround modes in Info.plist if you are using significant change location service (startMonitoringSignificantLocationChanges) to monitor user location in the background and in the app kill state.

    0 讨论(0)
  • 2020-12-25 15:52

    You're right about the location key, it's only required when your app needs high-precision location updates even when in the background. Something like Runkeeper uses this to allow it to keep tracking your location, even when you're using another app with multitasking. From the docs for iOS Keys: UIBackgroundModes

    "location": The app provides location-based information to the user and requires the use of the standard location services (as opposed to the significant change location service) to implement this feature.

    And

    Where alternatives for running in the background exist, those alternatives should be used instead. For example, apps can use the signifiant location change interface to receive location events instead of registering as a background location app.

    Region monitoring will work without the location key. In fact, region monitoring will work without any special iOS keys being enabled.

    You say that you're not using CLLocationManager, but if you're using region monitoring, you'll have to use that class. You need to set up a location manager delegate for your app to actually get the region notifications.

    0 讨论(0)
提交回复
热议问题