startUpdatingLocation(带距离过滤器)和 significantLocationChanges 之间的区别
Difference between startUpdatingLocation (with Distance Filter) and significantLocationChanges
我正在开发一个应用程序,大约 50 公里后需要更新位置。如果我将 locationManager
上的 distanceFilter
设置为 50000。调用 startUpdatingLocation
会比使用 startMonitoringSignificantLocationChanges
更省电吗? (视为 significantLocationChanges 不要使用 distanceFilter
)
根据提供的信息,startMonitoringSignificantLocationChanges
是正确的选择。原因和您的问题的答案是,startMonitoringSignificantLocationChanges
是您的应用程序注册的一项服务,即使您的应用程序被暂停或终止,它也会继续 运行。但是,startUpdatingLocations
是在应用程序级别注册的,除非您通过 requestAlwaysAuthorization
明确要求用户在后台获得 运行 的许可,否则您的位置服务将在应用程序暂停或终止时终止。您还需要为位置背景模式注册您的应用程序,并向 Apple 提供充分的理由或 运行 应用程序被拒绝的风险。
我正在开发一个应用程序,大约 50 公里后需要更新位置。如果我将 locationManager
上的 distanceFilter
设置为 50000。调用 startUpdatingLocation
会比使用 startMonitoringSignificantLocationChanges
更省电吗? (视为 significantLocationChanges 不要使用 distanceFilter
)
根据提供的信息,startMonitoringSignificantLocationChanges
是正确的选择。原因和您的问题的答案是,startMonitoringSignificantLocationChanges
是您的应用程序注册的一项服务,即使您的应用程序被暂停或终止,它也会继续 运行。但是,startUpdatingLocations
是在应用程序级别注册的,除非您通过 requestAlwaysAuthorization
明确要求用户在后台获得 运行 的许可,否则您的位置服务将在应用程序暂停或终止时终止。您还需要为位置背景模式注册您的应用程序,并向 Apple 提供充分的理由或 运行 应用程序被拒绝的风险。