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

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

Open praveenreddy9 opened this issue 2 years ago • 6 comments

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

praveenreddy9 avatar Jan 03 '23 13:01 praveenreddy9

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

jalaliyev avatar Jan 21 '23 11:01 jalaliyev

This will help you https://www.youtube.com/watch?v=sE0MEyFA7E4&list=PLQhQEGkwKZUrempLnmxjt7ZCZJu1W3p2i&index=10

BraveEvidence avatar Feb 25 '23 14:02 BraveEvidence

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.

stanjhae avatar Mar 20 '23 20:03 stanjhae

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)

OpenTasteSG avatar Mar 21 '23 15:03 OpenTasteSG

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.

stanjhae avatar Mar 21 '23 15:03 stanjhae

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

Phong95 avatar Mar 22 '23 08:03 Phong95

@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
  }
}

zoontek avatar Mar 28 '23 14:03 zoontek