React-native-permissions: Permissions.request("location") never resolves

Created on 19 Feb 2019  路  5Comments  路  Source: zoontek/react-native-permissions

Describe your environment

  • React-Native version: 0.58.4
  • Platform: iOS, Android, both?: Only tested on iOS
  • Device (which one?), simulator?: Simulator and iPhone X
  • OS version: iOS 12.1
  • react-native-permissions version: 1.1.1
  • Devtools: Xcode? Android Studio version?: VS Code

How to repeat issue and example

I'm simply running this code on the componentDidMount method:

  checkPermissions = async () => {
   Permissions.check('location', { type: 'whenInUse' }).then((response) => {
      console.tron.log(`locationPermission: ${response}`);
    },
    (error) => {
      console.tron.error(`There has been a problem with your fetch operation: ${error.message}`);
    }).catch(error => console.tron.error(error)); // error handling for promise
  }

Nothing appears... just get this error on reactotron:

line: 153447
column: 28
sourceURL: http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false

Additional Info

I'm using all UsageDescriptions in my info.plist and it does not work:

<key>NSBluetoothPeripheralUsageDescription</key>
  <string>Some description</string>
  <key>NSCalendarsUsageDescription</key>
  <string>Some description</string>
  <key>NSCameraUsageDescription</key>
  <string>Some description</string>
  <key>NSLocationUsageDescription</key>
    <string>GPS data is required to verify your commutes and generate rewards.</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Permitir acesso a sua localiza莽茫o para encontrarmos os prestadores mais pr贸ximos.</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Permitir acesso a sua localiza莽茫o para encontrarmos os prestadores mais pr贸ximos.</string>
  <key>NSPhotoLibraryAddUsageDescription</key>
  <string>Some description</string>
  <key>NSPhotoLibraryUsageDescription</key>
  <string>Some description</string>
  <key>NSSpeechRecognitionUsageDescription</key>
  <string>Some description</string>
  <key>NSAppleMusicUsageDescription</key>
  <string>Some description</string>
  <key>NSMotionUsageDescription</key>
  <string>Some description</string>

Most helpful comment

encountering the same error using Android

All 5 comments

encountering the same error using Android

Any fix for this?

It's getting undefined

Please check this. I will work.

Permissions.request('location').then(response => {
// Returns once the user has chosen to 'allow' or to 'not allow' access
// Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
this.setState({cameraPermission: response});
});

I am closing this since this issue does not exists anymore with the 2.0.0 release.

Was this page helpful?
0 / 5 - 0 ratings