iOS Location Services visits and system Frequent Location

依然范特西╮ 提交于 2020-01-01 00:34:53

问题


I noticed that Frequent Location on iPhone seems to use much less battery than an app monitoring iOS Visits (https://developer.apple.com/reference/corelocation/clvisit).

Frequent location on iPhone can be viewed on the phone via Settings -> Privacy -> Location Services -> System Services -> Frequent Locations.

I would like to know if Visit monitoring service from CLLocationManager is the same as iOS Frequent location or is it on different system used by Apple. If Apple is using the same service why it does not have any impact on the battery?


回答1:


The two APIs are intended for different purposes.

CLLocationManager API

This API is designed to inform your application of location information based on requirements which are indicated by your app. You may choose some specific conditions when your app receives location data, and your app will continue to receive that data until it is no longer desired. Think for example, the Uber app would request location data when opening the app so you can schedule a ride, and would keep requesting it as your ride approaches.

Frequent Locations / CLVisit API

By contrast Frequent Locations is different in that it does not consistently report location data to your app. Instead apps can indicate they want to know if a user visited a specific location, and if the user does then iOS will inform the application. Locations tend to be somewhat rough. This would be used in the example of the StarBucks app, when you arrive near a StarBucks the app may tell you about the nearby shop with a limited time sale to encourage you to stop in. For many of these apps, the user will generally select a pre-defined list of locations which they will mark as their "favorite" locations/stores and the app will use that data to notify the user.

Battery Life

Due to the difference in how both of these APIs operate the difference in battery usage becomes apparent. With CLLocationManager we begin and continuously report either an accurate/rough location to the app. GPS is normally used here in addition to cellular triangulation and wifi hotspot location data.

But with CLVisit, we typically only notify the app a single time upon the initial visit (or departure) of a desired location. Due to this iOS doesn't need to wake the app and do any additional processing if the current location isn't roughly gotten closer or farther away from where we are interested in reporting. The device can get a rough location using cellular triangulation and wifi hotspot location data. GPS is not generally needed for this level of location detail. Since your cellular radio and wifi are usually "always on" it doesn't drain any additional power to use these two methods for location detection.

But how can it use cellular and wifi to determine where I am?

Explaining how your device derives it's location from cellular or wifi signals is beyond the scope of this question. But here is an excellent post explaining a little about how that information is derived. How does Google know where I am? - security.stackexchange.com



来源:https://stackoverflow.com/questions/41037711/ios-location-services-visits-and-system-frequent-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!