React-native-push-notification: Library is returning "Native module cannot be null" with react-native version - 0.60.5 on iOS

Created on 6 Sep 2019  路  12Comments  路  Source: zo0r/react-native-push-notification

I have used react-native-push-notification on react-native < 0.60 versions, It is working fine but for RN version 0.60.5 it is returning "Native module cannot be null" for iOS.

Most helpful comment

This happened because react native is no longer exporting pushnotificationsIOS and the library hasn't updared yet, in order to fix it (until another release its made) you need to do the following:

follow the instruction to install the standalone version of pushnotificationIOS

then go to node_modules/react-native-push-notification/component/index.ios.js and replace the import of pushnotificationIOS from rreact-native with

import PushNotificationIOS from '@react-native-community/push-notification-ios';

That will fix it, but if you want a permanent solution you will need to wait for a release or use patch-package, i will probably submit a pr later to see if they merge the fix.

All 12 comments

Same for me.

This happened because react native is no longer exporting pushnotificationsIOS and the library hasn't updared yet, in order to fix it (until another release its made) you need to do the following:

follow the instruction to install the standalone version of pushnotificationIOS

then go to node_modules/react-native-push-notification/component/index.ios.js and replace the import of pushnotificationIOS from rreact-native with

import PushNotificationIOS from '@react-native-community/push-notification-ios';

That will fix it, but if you want a permanent solution you will need to wait for a release or use patch-package, i will probably submit a pr later to see if they merge the fix.

Hello !

Same here, but I checked the index.ios.js, and there is the correct import in this file. I installed the dependency "@react-native-community/push-notification-ios", but it is not working.

The commit with the modification of import was done 2 months ago, so the problem is really weird.
It seems the push-notification-ios package is correctly auto linking module, but the error persist on this line.

I managed to make it works. No need to change this line if you have last version of this module.

Just follow installation of standalone PushNotificationIOS,
don't forget to change your AppDelegate.m with new refs to RNCPushNotificationIOS,
don't forget to remove React-RCTPushNotificationIOS from Podfile, then pod install.

Clean and rebuild, normally it will be fine, I think this issue can be closed now :)

I went through this today and these were my steps:

  1. Install this package and link it.
  2. Install @react-native-community/push-notification-ios as instructed, but don't do the manual linking. The autolinking (react-native link @react-native-community/push-notification-ios) will add the pod to the Podfile.
  3. It should build successfully.

Thanks,
Alvaro

My upgrade path was a little more involved - posted here.


  1. Upgrade to latest: yarn add react-native-push-notification
  2. yarn add @react-native-community/push-notification-ios
  3. Ensure any references are removed from your Podfile (including commented references, or react-native will still complain)
  4. in Xcode, remove RNCPushNotification from General -> Linked Frameworks
  5. Remove previous PushNotification code from AppDelegate.m
  6. react-native link @react-native-community/push-notification-ios
  7. If this didn't add code in AppDelegate.m (it didn't in my case) then manually add the code from their GitHub page

One more gotcha - when testing that it works, make sure your app is closed or a local notification won't fire.

That's quite the breaking change, maybe the major version number should have been updated ?

the builtin lib is marked as deprecated in React Native, but it is still working.

@lukewlms there's one more step

  1. Delete the manual linking line that was added to your Podfile
    pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'
    then cd into ios/ and run pod install

I am experiencing this error.
Running pod install does nothing, whether that line is in the podfile or not. How can that be?

just doing yarn add @react-native-community/push-notification-ios and then cd into ios/ and run pod install solves Native module cannot be null for me, but even with all steps in place I don't get notifications actually working :(

Oh, nevermind, I forgot to add notification permissions request. Once i got permissions it started working :)

Tried the eight steps above. IT fixed it. Installed some other dependencies.. Error comes back. No idea how to fix it again.. Was a stupid idea to upgrade RN.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Benzer1406 picture Benzer1406  路  3Comments

ssolida picture ssolida  路  3Comments

sungjinoh picture sungjinoh  路  3Comments

anativ picture anativ  路  3Comments

selimonline picture selimonline  路  3Comments