I just upgrade React-native from 0.28 to 0.30, and get this error:
\"Native module cannot be null\".
The problem seem to be with the line/package:
remove react-native-push-notification in node_modules
run npm install react-native-push-notification@3.1.3
My issue had the same symptoms but a much different root cause. I had two React Native projects open in two different instances of Xcode. My Metro bundler was still running from Project A and causing problems running Project B in the simulator.
The fix: close the old terminal window spawned by Xcode that had the Metro Bundler running and re-run the project.
In my case, running a $ pod install
inside /ios directory did the trick!
npm i @react-native-community/push-notification-ios
cd ios && pod install
react-native unlink @react-native-community/push-notification-ios
That's how I solved it after struggling for hours.
Sometimes it can be an issue of when you install different libraries through npm
. All need to do is: go to the project's ios folder, and run pod install
. This will help to avoid this error, this is one of the reasons also.
Sometime, if you had another react-native packager already running for a different app. You may see this problem.
Especially if the react-native versions are same and the previously started app requires a native module which is not available in the current app.
In these cases, you can kill the react packager terminal and restart it and problem should go away.
Also if it is the same app and you just upgraded. Make sure that it is linked properly. If not call react-native link again.