ios: Invariant Violation: Native module cannot be null
At iOS, it builds successfully, however, when the app starts, I get this error:
Invariant Violation: Native module cannot be null.
constructor
NativeEventEmitter.js:36:6
<global>
PushNotificationIOS.js:17:32
loadModuleImplementation
require.js:321:4
guardedLoadModule
require.js:210:11
metroRequire
require.js:128:6
module.exports.get__PushNotificationIOS
react-native-implementation.js:257:11
<global>
index.ios.js:10:13
loadModuleImplementation
require.js:321:4
guardedLoadModule
require.js:210:11
Any idea?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 9
- Comments: 66
For those who are having trouble getting this module on 0.61.5, please run
pod installin youriosfolder.So solved this by adding manually
@react-native-community/push-notification-iostho it should be a dependencyHow did you fix this?
ok, my solution was: I had an old version 0.59 and now I have 0.61.5 I used react-native-push-notification for both platforms my solution was
pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios/RNCPushNotificationIOS.podspec'I am getting this same issue. not working even after installing from mainstream.
Same issue on 0.61.5. Only happens on iOS, Android is fine. Canât figure out which package it is or how to debug this. Any suggestions?
Hi! Iâm having the same issue. BUT I know what is the cause, itâs the package
react-navigation-stackorreact-navigation-tabs. They both use the packagereact-native-reanimatedwhich is creating the following error for me.I have tried everything that all of you already posted before me. And none of them have worked successfully, unfortunatelyâŚ
If anyone has any idea how to fix this issue. You would really help me out big time.
I am only getting this error when running my test:
Any solution to this?
Confirm. Have the same issue
I had to do this before including the package to make it work:
Environment: react-native: 0.64.2 jest: 26.6.3 @react-native-community/push-notification-ios: 1.8.0
Fixed this issue today with the following:
Itâs weird, you can comment out the return objects
addEventListenerandrequestPermissionsassignment and it continues to work, but if you try the following it doesnât:Add it to your jest setup file and never worry about it again.
@radetsky that is exactly what I did and it resulted in this error message.
Something is very simple. @react-native-community/push-notification-ios": â1.0.3â linked with Podfile after install and link commands. Just cd to ios/ and run âpod installâ. And restart the project.
FYI, for folks who are having issue using expo + expo-notifications. It seems like the lib is not ready for use yet.
I too am having the same issue as @netpoe. I have tried both âexpo-notificationsâ: â~0.1.1â and âexpo-notificationsâ: â^0.4.0â. Iâm currently using âexpoâ: â~37.0.3â. As soon as I add âimport * as Notifications from âexpo-notificationsâ;â to a file the app wonât load on iOS simulator.
I guess we are all waiting for updates on this one =/
Any updates with this one?
Environment:
"expo": "^37.0.0","expo-notifications": "~0.1.1",Iâm getting this error when using
expo-notificationsas described in the expo-documentation:Iâm using a managed workflow. This happens in iOS Simulator iPhone 8. Could it be that itâs because Iâm at the simulator? This error wonât happen in an Android device running the same app.
The code thatâs causing this is:
What I do get in Android is this warning:
Same error here with RN 59.10. I have patched above zo0r/react-native-push-notification@5b02761 manually. All code/setup steps in RN/XCode completed as per https://facebook.github.io/react-native/docs/pushnotificationios but no luck. Any ideas?
this has been solved, but now I got this issue: https://github.com/react-native-community/react-native-push-notification-ios/issues/44
expo-notifications is a separate package from this repository. For any issues regarding the expo-notification package, please use the issue tracker for the expo-notification repository
I was having the same issues here after adding âexpo-notificationsâ to my project.
I fixed it by creating a brand new blank project using latest version of expo
copying the files from my old project and reinstalling dependencies one by one as the compilation errors were presented. The first iâve installed was âexpo-notificationsâ btw.
If you want to make sure âexpo-notificationsâ is working and test it just create the new project, install this dependency and copy the App.js content from the example
https://docs.expo.io/versions/latest/sdk/notifications/
Only then migrate the files from your old project.
In My case, I commented the
use_native_modules!by mistake and thatâs why some of the node modules having podspecs where not getting installed and was the real culprit. I just uncommented it and thenpod install. It worked!I got the same issue as @Wout-Vanneste-student described. https://github.com/react-native-community/react-native-push-notification-ios/issues/43#issuecomment-562862506
This is how it worked for me; After I installed these libraries(described in the post in the link above) through
yarni had to do alsopod installand it worked.I was using version
v3.1.2ofreact-native-push-notificationwhich depends on outdatedPushNotificationIOS, installingreact-native-push-notificationfrom main stream fixed my issue.react-native-push-notificationneeds to create a new release to have this important commit: https://github.com/zo0r/react-native-push-notification/commit/5b02761d927cdacdc50fde41d58506f64d8154aa