Cordova iOS location message

后端 未结 5 1806
忘了有多久
忘了有多久 2020-12-19 01:37

I use the plugin cordova-plugin-geolocation. My only issue is that the message prompt to allow location looks like this:

/var/container/bundle/applica

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 02:25

    If you are targetting iOS 8 and later (I my opinion, no need to target older versions anymore...), there are two keys available for configuration:

    NSLocationAlwaysUsageDescription

    This key lets you describe the reason your app accesses the user’s location information at all times. Include this key when your app uses location services in a potentially nonobvious way while running in the foreground or the background. For example, a social app might include this key when it uses location information to track the user’s location and display other users that are nearby. In this case, the fact that the app is tracking the user’s location might not be readily apparent. The system includes the value of this key in the alert panel displayed to the user when requesting permission to use location services.

    NSLocationWhenInUseUsageDescription

    This key lets you describe the reason your app accesses the user’s location information while your app runs in the foreground and otherwise when in use. Include this key when your app uses location services to track the user’s current location directly. This key does not support using location services to monitor regions or monitor the user’s location using the significant location change service. The system includes the value of this key in the alert panel displayed to the user when requesting permission to use location services.

    So in your iOS project info.plist file you can add the following:

    NSLocationAlwaysUsageDescription
    my_project requires constant access to your location, even when the screen is off.
    

    Access location only when app is used

    NSLocationWhenInUseUsageDescription
    my_project requires access to your location only when being used.
    

提交回复
热议问题