React-native-permissions: undefined is not a object (evaluating 'RNPermissions.requestPermissions') RN = 0.31

Created on 19 Aug 2016  路  18Comments  路  Source: zoontek/react-native-permissions

Hi yonahforst, thanks for this module!

I'm unable do request location permission using RN 0.31. It seems like RN change it NativeModules structure and now this doens't work anymore

var RNPermissions = ReactNative.NativeModules.ReactNativePermissions;

So i get this error (title of this issue) in the line 81 of ReactNativePermissions.js

    requestPermission(permission, type) {
        let options;

        if (this.getPermissionTypes().indexOf(permission) === -1) {
            return Promise.reject(`ReactNativePermissions: ${permission} is not a valid permission type on ${Platform.OS}`)
        } else if (permission == 'backgroundRefresh'){
            return Promise.reject('ReactNativePermissions: You cannot request backgroundRefresh')
        } else if (permission == 'location') {
            options = type || 'whenInUse'
        } else if (permission == 'notification') {
            options = type || ['alert', 'badge', 'sound']
        }

        return RNPermissions.requestPermission(permission, options)
    }

I tried to fix it locally, but then an exception in BaseJavaModule.java was thrown. Something about a number of parameters.

is there other reports like this?

If you need more information, let me know

Most helpful comment

Hi, I'm getting this issue when I upgrade my RN version from 0.60.5 to 0.61.1 , I also upgrade my Xcode to the latest version 11.0

Can anyone share any solution to this issue. thanks

All 18 comments

I'm on 0.30.0, I'll try to test on 0.31.0 later this week. Can you double check that you've followed the linking steps for android correctly?

I'm having a similar issue with RN 0.30

@bnetter - sorry you're having trouble. Is it on iOS or Android? also, have you checked that the library is linked?

same issue with rn 0.29 on android - iOS works fine

Ok solved it -> rnpm link doesn't correctly link the project for android.
I did Step 3 manually and all is fine now.

Everything looks properly linked for me, and I'm getting the same error (on RN 0.30). Anything I should check?

@athaeryn - ios or android?

Just Android, sorry. iOS is working.

no probs. can you post a screenshot of your MainApplication and projects build.gradle?

Is anyone still having this issue?

If anyone still had this issue, comment here and I'll reopen

This problem still exists on my project (RN 0.35, Xcode8)

Have tried const Permissions = require('react-native-permissions'); but still fail.
Checked Xcode have libraries linked properly.

The module does not exist in NativeModules from "react-native"

FOR IOS:
I ran into this problem this week on 0.42.0

I solved this by manually linking the library, following the steps provided here:
https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking

I'm getting this same error. iOS and Android. All the linking went well.

"react-native": "0.44.0"
"react-native-permissions": "^0.2.7"

Help!

const Permissions = require('react-native-permissions')
Permissions.getPermissionStatus('location', 'whenInUse')
      .then(response => {
        console.log(response)
      })

EDIT:
If you're running into this issue, try executing react-native run-ios again (same for Android). That solved my issue. :)

@juancaacuna , thanks! It's so obvious that after linking the lib you need to recompile the app. And yet I didn't think of it and have been getting the error for a while :)

I have a problem in PermissionsIos.canOpenSettings on ios only.android works properly.please help

i have a problem in RNFIRMesaging.requestPermissions in library RN-FCM
i used RN - 0.46.3, FCM 10.0.3

screen shot 2018-05-04 at 09 27 21

Hi, I'm getting this issue when I upgrade my RN version from 0.60.5 to 0.61.1 , I also upgrade my Xcode to the latest version 11.0

Can anyone share any solution to this issue. thanks

Was this page helpful?
0 / 5 - 0 ratings