Always ask for permission in Cordoba Geolocation

It looks like PhoneGap has a config.xml parameter to update the plist key in the project, to set the rights to the Geolocation plugin from “while in use” to “always”, and if I manually set my project file .plist file to NSLocationAlwaysUsageDescriptioninstead of the default plugin NSLocationWhenInUseUsageDescriptionit sets the correct permission, but how can I tell the plugin to request permission to Always, without burying itself in the plists / ios / * file. plist? It looks like there is a check in the plugin code to find out what permission to set, but I can't figure out how to request that it ask the user for the correct permissions with the JavaScript API.

See: https://github.com/apache/cordova-plugin-geolocation/blob/master/src/ios/CDVLocation.m#L130

+4
source share
1 answer

Go to the /ios/ios.json platform Find the following:

 "*-Info.plist": {
                    "parents": {
                        "NSLocationWhenInUseUsageDescription": [
                            {
                                "xml": "<string />",
                                "count": 1
                            }
                        ]
                    }
                }

And replace "NSLocationWhenInUseUsageDescription" with "NSLocationAlwaysUsageDescription" This is what the following looks like:

"*-Info.plist": {
            "parents": {
                "NSLocationAlwaysUsageDescription": [
                    {
                        "xml": "<string />",
                        "count": 1
                    }
                ]
            }
        }

Launch "cordova build ios"

+1
source

All Articles