react-native icon indicating copy to clipboard operation
react-native copied to clipboard

iOS: Geolocation with NSLocationAlwaysUsageDescription

Open oniisanlabs opened this issue 10 years ago • 5 comments

I use version 0.17.0 of React Native

Geolocation works for me if I use NSLocationWhenInUseUsageDescription like mentioned in the documentation on https://facebook.github.io/react-native/docs/geolocation.html. Unfortunately it doesn't ask for the permissions if I specify NSLocationAlwaysUsageDescription in my Info.plist. Is this a known issue?

Could also be related to #4879

oniisanlabs avatar Dec 20 '15 14:12 oniisanlabs

Hey seb0zz, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or not sure whether some behavior is expected or a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

facebook-github-bot avatar Dec 20 '15 14:12 facebook-github-bot

@seb0zz I think if you've accepted Location permissions once it won't ask you again unless you clear the settings.

It might be easier to just setup a new app and test NSLocationAlwaysUsageDescription.

I've used this in the past and it worked fine so you shouldn't have any problems.

christopherdro avatar Dec 20 '15 17:12 christopherdro

@christopherdro That was my first thought, too. So I tested my app on a real iOS device. I am now able to reproduce the problem by the following steps:

  1. Add NSLocationWhenInUseUsageDescription to my plist file
  2. Deploy to my real device
  3. Get asked for permissions
  4. Uninstall the app from my real device
  5. Change the key in my plist file to NSLocationAlwaysUsageDescription
  6. Deploy to my real device
  7. Not receiving any request for permissions
  8. Uninstall again and redeploy with NSLocationWhenInUseUsageDescription
  9. Get asked for the permissions again

oniisanlabs avatar Dec 20 '15 20:12 oniisanlabs

When I test this on master NSLocationAlwaysUsageDescription does not get ignored but throws an error message.

image

oniisanlabs avatar Dec 22 '15 23:12 oniisanlabs

@seb0zz - you can add both and NSLocationWhenInUseUsageDescription will be ignored - https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW18

If you want to fix this, it should be a very easy PR :) https://github.com/facebook/react-native/blob/master/Libraries/Geolocation/RCTLocationObserver.m#L328-L333 - just update this block to check for either of them. I will merge right away! :rocket:

brentvatne avatar Dec 24 '15 22:12 brentvatne