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.
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:
Thanks,
Alvaro
My upgrade path was a little more involved - posted here.
yarn add react-native-push-notificationyarn add @react-native-community/push-notification-iosreact-native link @react-native-community/push-notification-iosOne 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
Podfilepod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'ios/ and run pod installI 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.
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.jsand replace the import of pushnotificationIOS from rreact-native withimport 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.