Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native-location warning:403 #136

Open
kevin871223 opened this issue Jun 20, 2020 · 5 comments
Open

react-native-location warning:403 #136

kevin871223 opened this issue Jun 20, 2020 · 5 comments

Comments

@kevin871223
Copy link

react-native:0.58.4

react-native-location warning:
type:403
Attempted to start updating the location without location permissions. Detail: "gps" location provider requires ACCESS_FINE_LOCATION permission.

thanks!!

@Feofilov
Copy link

Feofilov commented Apr 12, 2021

react-native:0.58.4

react-native-location warning:
type:403
Attempted to start updating the location without location permissions. Detail: "gps" location provider requires ACCESS_FINE_LOCATION permission.

thanks!!

Android API >= 23 Requires an additional step to check for, and request the ACCESS_FINE_LOCATION permission using the PermissionsAndroid API. Failure to do so may result in a hard crash.

You can use something like this before trying to get geolocation:

import { PermissionsAndroid } from 'react-native'
...
try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
      {
        title: "Cool App Location Permission",
        message:
          "Cool App needs access to your location ",
        buttonNeutral: "Ask Me Later",
        buttonNegative: "Cancel",
        buttonPositive: "OK"
      }
    );
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      console.log("Now you can use geolocation!");
    } else {
      console.log("Location permission denied");
    }
  } catch (err) {
    console.warn(err);
  }
  ...

@qasimmehdi
Copy link

I am also getting the same error above solution did not help.

   RNLocation.configure({
      distanceFilter: 0, // Meters
      desiredAccuracy: {
        ios: 'best',
        android: 'highAccuracy',
      },
      interval: 1000,
      maxWaitTime: 1000,
    });


   RNLocation.requestPermission({
      ios: 'whenInUse',
      android: {
        detail: 'fine',
        rationale: {
          title: 'Location permission',
          message: 'We use your location to demo the library',
          buttonPositive: 'OK',
          buttonNegative: 'Cancel',
        },
      },
    })

This is only happening when desiredAccuracy is highAccuracy.

@qasimmehdi
Copy link

qasimmehdi commented Apr 20, 2021

I solved the issue in android.
Add these lines in AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Then in android/app/build.gradle add these lines in dependencies

implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.android.gms:play-services-location:16.0.0"

Just follow the installation instructions correctly and it will work.

@bimix
Copy link

bimix commented Apr 14, 2022

I solved the issue in android. Add these lines in AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Then in android/app/build.gradle add these lines in dependencies

implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.android.gms:play-services-location:16.0.0"

Just follow the installation instructions correctly and it will work.

I already have all of them and still shows the warning

@mehdinourollah
Copy link

any updates ?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants