Location permission alert on iPhone with Cordova

前端 未结 3 1711
天命终不由人
天命终不由人 2020-12-03 19:55

I\'m working on a cordova app on which I have to locate the user latitude and longitude. Using the geolocation plugin, it works fine on android dev

3条回答
  •  星月不相逢
    2020-12-03 20:33

    Same as the "edit" in the original question, I had to remove the old version of the geolocation plugin and add the new one. Then I had to remove/add the Cordova iOS platform. Only then could I add NSLocationWhenInUseUsageDescription to the .plist file as DaveAlden mentions in his answer with success.

    First, remove/add the geolocation plugin:

    cordova plugin rm org.apache.cordova.geolocation
    cordova plugin add org.apache.cordova.geolocation
    

    Second, remove/add the iOS platform:

    cordova platform rm ios
    cordova platform add ios
    

    Last, add NSLocationWhenInUseUsageDescription to the .plist. Open /platforms/ios/{project}/{project}-Info.plist and add the following:

    NSLocationWhenInUseUsageDescription
    [App Name] would like to access your location when running and displayed.
    

    See this iOS Developer Library link for detailed information regarding NSLocationWhenInUseUsageDescription versus NSLocationAlwaysUsageDescription versus NSLocationUsageDescription.

提交回复
热议问题