Add the appropriate “Tag” based on what Expo library you have a question on.
My app only needs foreground location permission, but expo-location would automatically add NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription. I’m able to set the purpose string in app.json or with plugin configuration but I can’t remove them.
I saw some old documentation that says I could put an empty string or null as a value then the key won’t be added but that also doesn’t work after I try.
The locationWhenInUsePermission property is undocumented.
Is it necessary to remove NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription?
I would have thought that as long as your Info.plist does not have the UIBackgroundModes section with value location, and you never call useBackgroundPermissions() or getBackgroundPermissionsAsync() and you have a reasonable value for locationWhenInUsePermission it should be fine. Is this not the case?
So I would try something like this:
"locationWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location when you are using the app.",
If you still have problems, maybe you could try adding something like this to the above:
"locationAlwaysAndWhenInUsePermission": "$(PRODUCT_NAME) does not access your location in the background. If you see this message, contact firstname.lastname@example.org",
"locationAlwaysPermission": "$(PRODUCT_NAME) does not access your location in the background. If you see this message, contact email@example.com",
It will depend on my next app store review’s result whether I have to remove NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription given that my app doesn’t need any background location capability. I’ll share the result when I get it. My last submission was rejected because I used this text directly - “Allow $(PRODUCT_NAME) to use your location when you are using the app.” the reviewer told me to change it to be more specific and clear. And they also want me to explain how location service is used by my app’s feature, so I don’t know if they would take it as a problem if these two “always” keys are included in the Info.plist.
Two other things worth mentioning are -
When all these three keys are present, the settings screen would take the description of NSLocationAlwaysAndWhenInUseUsageDescription, so I actually need to add my description to locationAlwaysAndWhenInUsePermission. The system popup prompt doesn’t have such a problem and will use locationWhenInUsePermission.
If an app includes NSLocationAlwaysAndWhenInUseUsageDescription, the settings screen would show the “always” option, otherwise it doesn’t.
I would have to test out the functionality to see exactly what’s going on, but I think maybe a proper fix would be to only include the ones mentioned in app.json, except maybe if isIosBackgroundLocationEnabled is true.
This patch works great and is exactly what I need. My app’s working properly without those two ‘always’ keys now and I can report back if there’s any issue.
And I think what you said makes total sense - expo-location should only include NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription if user sets isIosBackgroundLocationEnabled to true.