I develop an app that uses geolocation for iOS using Ionic 3. The app was rejected I need to change the app request for location message.
I follow the iOS quirk mention in cordova geolocation plugin page without luck:
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>need location access to find things nearby</string>
</edit-config>
I tried another variable NSLocationAlwaysUsageDescription, and both variables. I uninstall and install again the geolocation plugin. I try many answer to "similar" questions but nothing seems to work.
Somethings to note:
I also use BackgruondGeolocation plugin.
Part of the packages
“#ionic-native/background-geolocation”: “^4.12.2”,
“#ionic-native/core”: “~4.11.0”
“#ionic-native/geolocation”: “^4.12.0”,
…
“ionic-angular”: “3.9.2”
I notice that if i add the <edit-config> entry at the end of <platform name="ios"> it gives me a conflict message when building but it ends, no message if it is at the start. It does not work either way.
Please someone help me.
According to the documentation, you have to add this key to your Info.plist :
NSLocationWhenInUseUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationAlwaysUsageDescription
You are required to include the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription keys in your app's Info.plist file. (If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription key is also required.) If those keys are not present, authorization requests fail immediately.
Related
I tried changing in the AppName-Info.plist to the description I want but after the build it gets automatically replaced by the default one over below.
<key>NSLocationWhenInUseUsageDescription</key>
<string>$NSLocationWhenInUseUsageDescription</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>$NSLocationAlwaysUsageDescription</string>
I also tried removing the cordova geolocation plugin and reinstalling as
cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git --variable GEOLOCATION_USAGE_DESCRIPTION="Allow location access for maps"
but still it doesn't change the description. What I still get on my app is $NSLocationWhenInUseUsageDescription as my description.
I'm a little late to this post but I came across it while searching for an answer to the same problem. I ended up adding the following code to my ionic project config.xml file and after building and testing I can confirm that this worked.
<config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
<string>This app requires access to your location when the screen is on and the app is displayed to Lorem Ipsum. Your code here.</string>
</config-file>
I also attached a picture showing where that bit of code went in terms of the rest of the file.
Location Permission Example
I have a Cordova app that runs in iOS phones. I'm trying to send an update of this app to App Store, but it is being rejected. Firstly it was rejected because the info.plist contained a line with the key NSBluetoothPeripheralUsageDescription and this feature is never used in my app. To solve this problem I removed this line from info.plist and the respective framework from Linked Frameworks and Libraries in xCode (the framework CoreBluetooth.framework and the line NSBluetoothPeripheralUsageDescription was added by Cordova Diagnostic Plugin), as can be seen in the image below:
However now I'm receiving a e-mail from iTunes Connect saying this:
Missing Info.plist key - This app attempts to access privacy-sensitive
data without a usage description. The app's Info.plist must contain an
NSBluetoothPeripheralUsageDescription key with a string value
explaining to the user how the app uses this data.
But I removed the CoreBluetooth.framework from the xCode project...
My question is: I need to remove this framework from another place? Are some other framework able to use bluetooth causing this problem?
Thanks for help.
Open Info Plist file and press on + sign add new key in info.plist of your project and add this NSBluetoothPeripheralUsageDescription and write value "Explain the reasons for bluetooth"
Check Screen shot below
It appears that you cannot have a generic text string like:
We need access to your bluetooth connection.
I had something like this and got rejected. When I had a more detailed description like:
We need access to your bluetooth connection to upload data from your
device for crash reports.
I was approved.
The descriptions are mandatory for any content you or any frameworks you link against attempt to access. The errors are generated upon an attempt to access the content if a usage description was not supplied, so if you're getting those errors your app must be requesting them. You should discover why your app or its frameworks require these and add appropriate usage descriptions to your app's info.plist.
Or more ideally, if you don't need access, see if there's a way to not request it (or use frameworks that do unnecessarily).
For time being you can add the following descriptions in your info.plist and submit your app (in case of urgent app update)
<key>NSCalendarsUsageDescription</key>
<string>Explain the reasons for accessing...</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Explain the reasons for accessing...</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Explain the reasons for accessing...</string>
Just open your info.plist and add the code above accordingly.
Try to add below in your plist. It solve my problem.
<config-file parent="NSPhotoLibraryUsageDescription" platform="ios" target="*-Info.plist">
<string>YourAppName would like to store a photo.</string>
</config-file>
I found this thread because I had the same problem.
My experience was that I had installed a Bluetooth package with cordova, but, the experiment fail, and with the new copiles has this issue.
I checked the package.json, the package-lock.json and that I removed all the refences to my code. But, still falling.
Then I checked the pods bundle and found the Bluetooth bundle, but still failing.
I remove and add the platform ios and still falling.
Then I check the project and in the plugins folder I have the Bluetooth plugins folder. Removed, Compiled and works again.
I hope to help you.
I use the plugin cordova-plugin-geolocation. My only issue is that the message prompt to allow location looks like this:
/var/container/bundle/application/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/my_project/www/index.html
Would like to use your location.
Is there anyway to have something a little bit sexier, like
my_project would like to use your location
Cheers.
Added some code, for the non believers
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
navigator.geolocation.getCurrentPosition(onLocationSuccess, onLocationError, {maximumAge:3000, timeout:2000, enableHighAccuracy:true});
function onLocationSuccess(){
}
function onLocationError(){
}
}
The solution has changed for cordova-plugin-geolocation: "4.0.0". This is what you need to add in your config.xml:
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>need location access to find things nearby</string>
</edit-config>
For more information: https://github.com/apache/cordova-plugin-geolocation
From docs:
iOS Quirks
Since iOS 10 it's mandatory to add a NSLocationWhenInUseUsageDescription entry in the info.plist.
NSLocationWhenInUseUsageDescription describes the reason that the app
accesses the user's location. When the system prompts the user to
allow access, this string is displayed as part of the dialog box. To
add this entry you can pass the variable GEOLOCATION_USAGE_DESCRIPTION
on plugin install.
Example: cordova plugin add cordova-plugin-geolocation --variable
GEOLOCATION_USAGE_DESCRIPTION="your usage message"
If you don't pass the variable, the plugin will add an empty string as
value.
To solve your problem, try:
Uninstall the plugin:
cordova plugin remove cordova-plugin-geolocation
Reinstall with:
cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="my_project would like to use your location"
There are 3 possible reasons for displaying the path to the index.html instead of the name of your app:
You have not installed the plugin (or it's not installed correctly)
You are not waiting for the device ready event to call the plugin
You have not linked the cordova.js file in the index.html
As you say that you have installed the plugin and you are using it on device ready event, then it must be that you have forgotten to link the cordova.js in the index.html or the plugin wasn't installed correctly.
Check that you have the cordova.js linked and if you have it, remove the plugin and add it again, removing and re adding the iOS platform might help too
It seems like the version 3.0.0 of cordova-plugin-geolocation ignores the install parameter
--variable GEOLOCATION_USAGE_DESCRIPTION=""
like Bruno Peres said above.
It works fine for me installing the 2.4.3 version.
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:
<key>NSLocationAlwaysUsageDescription</key>
<string>my_project requires constant access to your location, even when the screen is off.</string>
Access location only when app is used
<key>NSLocationWhenInUseUsageDescription</key>
<string>my_project requires access to your location only when being used.</string>
Upon updating to iOS 10, when trying to access the contacts through plugin cordova-plugin-contacts v2.2.0, the app exits with
__CRASHING_DUE_TO_PRIVACY_VIOLATION__
I don't know what other extra info i can provide right now, just let me know if i can be more specific. Thanx.
Maybe this is of some use: https://stackoverflow.com/a/39416858/592641, but i couldn't find a guide of how to specify those usage descriptions in cordova.
After creating an Xcode project and finding the Info.Plist file, you may try adding NSContactsUsageDescription key, which should accept a string value.
A complete list of Cocoa Keys
Hope that helps!
EDIT
A part from the doc: (which can help you understand why it is crashing)
Important: To protect user privacy, an iOS app linked on or after iOS
10.0, and which accesses the user’s contacts, must statically declare the intent to do so. Include the NSContactsUsageDescription key in
your app’s Info.plist file and provide a purpose string for this key.
If your app attempts to access the user’s contacts without a
corresponding purpose string, your app exits.
My app was missing NSFaceIDUsageDescription key
In short, the usage descriptions need to be specified inside *info.plist
That's no good for Cordova codebase since .plist files are not part of the repository. The simplest way I found to put them inside config.xml is this:
Install cordova-custom-config
Add the following inside config.xml:
.
<platform name="ios">
<config-file parent="NSContactsUsageDescription" target="*info.plist">
<string>Easily invite your friends</string>
</config-file>
</platform>
My Info.plist was missing NSPhotoLibraryAddUsageDescription. There are now TWO permissions associated with the photo library (starting iOS 11):
NSPhotoLibraryUsageDescription - to access the photo library
NSPhotoLibraryAddUsageDescription - write only permission to photo library
I had the first permission prior to iOS 11 when it was the only key needed to use the photo library. Apparently in iOS 11 they added the second and made it required to add photos to the library. So if you support iOS 10 but don't include the second key, you will crash on iOS 11.
All Keys are Here
For me, I was trying to request access to the microphone, but I hadn't defined the Privacy - Microphone Usage Description string.
Go into your Info.plist file, and scroll down to the values that start with Privacy. Make sure you add keys and string values for everything relevant to your app.
I got here with the same error using Kudan AR via Unity, and #NeverHelpless's answer was on target, except the fix was NSCameraUsageDescription (Add to Info.plist with a description string)
If you are clear the issue is when accessing Contacts, then follow instructions posted on above answers.
But if those didn't help you, you may want to read my related answer here on other possible solutions (if you are using Bluetooth on your app):
https://stackoverflow.com/a/60073667/457202
Does anyone have experience using cordova, html and know how to fix this geolocation message issue for iOS? I just want the message to say the app name followed by the line, "would like to use your current location."
Current Geolocation Message:
///Users/kklsndksjladn/Library/Developer/CoreSimulator/Devices/FAF7EE4C-40BA-430A-80D5-5C84B07D970D/data/Containers/Bundle/Application/DAE305B6-C6DD-438B-B4D7-9B183A8B2D97/HelpME.app/www/index.html
I've tried various solutions from stack overflow and other websites. I implemented the navigator.geolocation.getCurrentPosition(onSuccess, onError); code, included my cordova.js file in every html page, made sure <script> src=cordova.js</script> appears first in my index.html page, included the geolocation tag in my config.xml file and tried playing around with my plist. Someone please help!!!!
-Thanks
In addition to the answer from DaveAlden, 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 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:
<key>NSLocationWhenInUseUsageDescription</key>
<string>[App Name] would like to access your location when running and displayed.</string>
See this iOS Developer Library link for detailed information regarding NSLocationWhenInUseUsageDescription versus NSLocationAlwaysUsageDescription versus NSLocationUsageDescription.
Location permission alert on iPhone with Cordova is a possible duplicate.
To customise the iOS location permission request message, you need to add a property to your project's .plist.
If your app requests permission to use location in the background, you want the following key (set the string value to anything you like):
<key>NSLocationAlwaysUsageDescription</key>
<string>My app requires constant access to your location, even when the screen is off.</string>
If your app only uses location while in the foreground, then add the following key:
<key>NSLocationWhenInUseUsageDescription</key>
<string>My app requires access to your location when the screen is on and the app is displayed.</string>