React-native-push-notification: Invariant Violation: Native module cannot be null.

Created on 30 Dec 2019  路  6Comments  路  Source: zo0r/react-native-push-notification

I have tried the example code wont work
I tried to import PushNotification from 'react-native-push-notification'; Wont work I installed npm i @react-native-community/push-notification-ios and still wont work
any help ?

Most helpful comment

I also had the same issue and this is what I did to solve:

  1. @react-native-community/push-notification-ios has already been installed as a dependency of react-native-push-notification. So you do not need to install it separately
  2. Update your podfile by adding this pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'
  3. Run pod install in the ios folder
  4. In your AppDelegate.m, update this https://github.com/react-native-community/react-native-push-notification-ios#update-appdelegatem

All 6 comments

I have tried the example code wont work
I tried to import PushNotification from 'react-native-push-notification'; Wont work I installed npm i @react-native-community/push-notification-ios and still wont work
any help ?

I had the same Issue...
What I did is install the push-notification-ios, just like you did. Just installing won't help.

  • Did a pod install (Unsure If it works or not but still do it)
  • Do this, it worked: I manually linked the push-notification-ios, the instructions are given on their page.

@TheHunterDog

This happened to me when I updated react-native-push-notification package.

To resolve this, follow install instructions at https://github.com/react-native-community/react-native-push-notification-ios, then, to avoid duplicate symbols issue, remove this line from podfile if you have it:

pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'

I also had the same issue and this is what I did to solve:

  1. @react-native-community/push-notification-ios has already been installed as a dependency of react-native-push-notification. So you do not need to install it separately
  2. Update your podfile by adding this pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'
  3. Run pod install in the ios folder
  4. In your AppDelegate.m, update this https://github.com/react-native-community/react-native-push-notification-ios#update-appdelegatem

i am also experiencing this. the above solutions dont seem to work : /

Close the simulator and re-run/re-build.
Worked for me.

I also had the same issue and this is what I did to solve:

  1. @react-native-community/push-notification-ios has already been installed as a dependency of react-native-push-notification. So you do not need to install it separately
  2. Update your podfile by adding this pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'
  3. Run pod install in the ios folder
  4. In your AppDelegate.m, update this https://github.com/react-native-community/react-native-push-notification-ios#update-appdelegatem

This helped me really much will close issue now Thank you so much

Was this page helpful?
0 / 5 - 0 ratings