ios
ios copied to clipboard
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?
this has been solved, but now I got this issue: https://github.com/react-native-community/react-native-push-notification-ios/issues/44
How did you fix this?
I was using version v3.1.2
of react-native-push-notification
which depends on outdated PushNotificationIOS
, installing react-native-push-notification
from main stream fixed my issue.
react-native-push-notification
needs to create a new release to have this important commit: https://github.com/zo0r/react-native-push-notification/commit/5b02761d927cdacdc50fde41d58506f64d8154aa
I am getting this same issue. not working even after installing from mainstream.
Sometimes, closing XCode and open in again then build would solve the issue.
@hopewise can you please open this again? I am still experiencing this issue
"react": "16.9.0",
"react-native": "0.61.4",
"@react-native-community/push-notification-ios": "1.0.3",
Edit: we are using react-native-push-notification package. So not 100% sure the error lies in this package. But it seems that several people on RN version 61.4 are experiencing this error.
@schumannd opened..
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.
@radetsky that is exactly what I did and it resulted in this error message.
+1 Same error here.
+1 Same error here. React Native 0.61.5
+1 Same error here. react-native 0.61.4
+1 Same error here on react-native 0.61.5
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?
Hi! I'm having the same issue. BUT I know what is the cause, it's the package react-navigation-stack
or react-navigation-tabs
. They both use the package react-native-reanimated
which 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.
So, here's the solution that worked for me for Xcode legacy build systems: remove react-native core IOS xcodeproj project from libraries, also, remove one that comes with react-native-push-notification (Push notification manager something) and add new XCodeProj file from this iOS project from below node_modules path. Also add path to Xcode > build settings > header search path > add $(SRCROOT)/../node_modules/@react-native-community/push-notification-ios/ios (non-recursive)
Path for XCodeproj - $(SRCROOT)/../node_modules/@react-native-community/push-notification-ios/ios

Hello, have you solved it?
+1 Same error here on react-native
0.61.5
Hello, have you solved it?
same error here 0.61.5
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 yarn
i had to do also pod install
and it worked.
Same problem here. 0.61.5
The same problem also 0.61.5 react-native version
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?
For those who are having trouble getting this module on 0.61.5, please run pod install
in your ios
folder.
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
- remove the package, yarn remove react-native-push-notification
- delete last code in xcode appdelegate.m
/*#import <React/RCTPushNotificationManager.h>*/ - //here
#import <UserNotifications/UserNotifications.h>
@implementation AppDelegate
/*- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
[RCTPushNotificationManager didReceiveLocalNotification:notification];
}*/ - //here
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"projectName"
initialProperties:nil];
- install again, yarn add react-native-push-notification
- add in pod file this line
pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios/RNCPushNotificationIOS.podspec'
- cd ios/ && pod install clear package and build in xcode again it works for me ;)
Same problem here. 0.59.8
@inmaSecret is this code working for u in ios? For me notification is not showing, but working fine in android
@inmaSecret is this code working for u in ios? For me notification is not showing, but working fine in android
the block code in xcode appdelegate.m related to pushNotification should be removed. my problem was that the appdelegate code left old RCTPushNotificationManager functionality after delete this I could fix the problem. Could you solve your problem with my solution finally?, it works for me in both
@inmaSecret thanks, it worked for me. but still issue with getting messages while app in background in ios. I am sending data mesasges. any suggestion ?
I am getting this issue as well. Unfortunately, none of the above solutions have worked for me.