Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

For IOS getting ERROR TypeError: null is not an object (evaluating 'NativeModule.requestPermission' #403

Open
praveenreddy9 opened this issue Jan 3, 2023 · 6 comments

Comments

@praveenreddy9
Copy link

praveenreddy9 commented Jan 3, 2023

What's happening?

For Android its working properly during IOS scan getting the error as ERROR TypeError: null is not an object (evaluating 'NativeModule.requestPermission' but i have installed by following the steps.

Please help me fix the issue or suggest the changes required.

How can it be reproduced?

If we try to use the qr code scanner code in render its getting the above error but with the same code its working in Android

                               <QRCodeScanner
                                    onRead={this.barcodeReceived.bind(this)}
                                    style={{flex: 1}}
                                    cameraStyle={{height: Dimensions.get('window').height}}
                                    showMarker={false}
                                    fadeIn={false}
                                    reactivate={true}
                                    cameraType={"back"}
                                />

Build details

"react": "17.0.2",
"react-native": "0.66.4",
"react-native-permissions": "^3.6.1",
"react-native-qrcode-scanner": "^1.2.1",

Simulator Screen Shot - iPhone 13 - 2023-01-03 at 19 09 33

Simulator Screen Shot - iPhone 13 - 2023-01-03 at 19 09 49

@jalaliyev
Copy link

jalaliyev commented Jan 21, 2023

try this one:
react-native-permissions
You will also need to install react-native-permissions to handle camera related permissions

npm install react-native-permissions --save
react-native link react-native-permissions
For iOS, as part of the react-native-permissions setup you will need to add the following code to your Podfile

permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
You may also need to reset your simulator data after adding those permissions Device -> Erase All Content and Settings...

More Info

@BraveEvidence
Copy link

@stanjhae
Copy link

stanjhae commented Mar 20, 2023

After spending two days debugging react-native-permissions, I found the issue is with react-native-qrcode-scanner.

It has "react-native-permissions": "^2.0.2" in it's dependencies but the current version is "react-native-permissions": "^3.8.0".

This version of react-native-permissions (3.8.0) has breaking changes.

Quick fix

  1. Install react-native-permissions.
  2. Most importantly, remember to add "reactNativePermissionsIOS": ["Camera"] and "postinstall": "react-native setup-ios-permissions && pod-install" to your package.json.
  3. Run npm install.
  4. Delete node_modules/react-native-qrcode-scanner/node_modules/react-native-permissions because it installs the deprecated 2.0.2. (You'll need to do this each time you clear your node_modules).
  5. Your QR code scanner should be working again 🥳.

The postinstall goes in the scripts section of your package.json.
You'll also need "pod-install": "0.1.38".

If you still have issues, delete your node_modules, package.lock and run pod deintegrate. Then retry the steps.

PR Options

I can create a PR to fix this issue. We have two options:

  1. Take out the react-native-permissions dependency and update the readMe so everyone knows to install the dependency themselves and set it up properly.
  2. Update the dependency and add the necessary steps. (reactNativePermissionsIOS and postinstall).

Please react with 👍 for option 1 and 🚀 for option 2.

@OpenTasteSG
Copy link

OpenTasteSG commented Mar 21, 2023

Seem to have this error even after following the above steps on ios

duplicate symbol 'OBJC_CLASS$_RNPermissionHandlerCamera' in

libPermission-Camera.a(RNPermissionHandlerCamera.o)
libRNPermissions.a(RNPermissionHandlerCamera.o)

❌ duplicate symbol 'OBJC_METACLASS$_RNPermissionHandlerCamera' in

libPermission-Camera.a(RNPermissionHandlerCamera.o)
libRNPermissions.a(RNPermissionHandlerCamera.o)

❌ ld: 2 duplicate symbols for architecture x86_64

❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)

@stanjhae
Copy link

Seem to have this error even after following the above steps on ios

duplicate symbol 'OBJC_CLASS$_RNPermissionHandlerCamera' in

libPermission-Camera.a(RNPermissionHandlerCamera.o)
libRNPermissions.a(RNPermissionHandlerCamera.o)

❌ duplicate symbol 'OBJC_METACLASS$_RNPermissionHandlerCamera' in

libPermission-Camera.a(RNPermissionHandlerCamera.o)
libRNPermissions.a(RNPermissionHandlerCamera.o)

❌ ld: 2 duplicate symbols for architecture x86_64

❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)

Did you take out the prior react-native-permissions installation steps from your podfile?

In the past, you had to add the pods being used by react-native-permissions to your podfile. That's no longer needed.

@Phong95
Copy link

Phong95 commented Mar 22, 2023

Seem to have this error even after following the above steps on ios
duplicate symbol 'OBJC_CLASS$_RNPermissionHandlerCamera' in

libPermission-Camera.a(RNPermissionHandlerCamera.o)
libRNPermissions.a(RNPermissionHandlerCamera.o)

❌ duplicate symbol 'OBJC_METACLASS$_RNPermissionHandlerCamera' in

libPermission-Camera.a(RNPermissionHandlerCamera.o)
libRNPermissions.a(RNPermissionHandlerCamera.o)

❌ ld: 2 duplicate symbols for architecture x86_64
❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)

Did you take out the prior react-native-permissions installation steps from your podfile?

In the past, you had to add the pods being used by react-native-permissions to your podfile. That's no longer needed.

i face same issue, follow your instruction, everything works now. You save my day, bro

@zoontek
Copy link

zoontek commented Mar 28, 2023

@stanjhae Option 1 is better since reactNativePermissionsIOS should be in user project package.json, couldn't be set in the library package.json.

The proper way to do it is to update this lib package.json like this:

"peerDependencies": {
  "react-native-permissions": "the-minimal-version-you-want-to-use"
},
"peerDependenciesMeta": {
  "react-native-permissions": {
    "optional": true
  }
}

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

No branches or pull requests

7 participants