iOS Location Services visits and system Frequent Location

前端 未结 1 957
盖世英雄少女心
盖世英雄少女心 2021-02-06 15:27

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).

<
1条回答
  •  灰色年华
    2021-02-06 16:22

    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

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