Description:
I followed all the step in the documentation for React-Native-OneSignal SDK setup and I ended up receiving a RCTAnimationType.h file missing error. I have been looking through a ton of other issue post but none of them are helpful, so for the love of god please do not point me to another useless "solved" issue and actually help me out on this problem.
(your description here)
Environment
Steps to Reproduce Issue:
Anything else:
(crash stacktraces, as well as any other information here)
This problem occur if I have Notification Service Extension enabled. But if I don't, whenever I would send a message from the Test Dashboard on onesignal.com, it would: 1. Crash my app when I have the app on the foreground and the message is sent. 2. Crash my app when I try to open the application through push notification banner.
Occasionally if I attempt to build the application enough time with the RCTAnimationType.h file missing, it will prompt that I now have RCTDefines.h file missing as well. Also sometime, either RCTDefines.h, or RCTAnimationType will be missing if I attempt to build the application.
Update:
I have solved the issue myself, now I am facing one of the listed sub issue. When my application is closed and I try to launch it through the notification banner it will crash on launch. Also when I am in the app and send a notification from dashboard it will crash on sent. Happened on iOS due to it being the only platform I am working on right now.
Error message in Xcode after I send a message from the dashboard to my app with it open:
libc++abi.dylib: terminating with uncaught exception of type NSException
Make sure to link the package correctly. Should be react-native link react-native-onesignal (you forgot the third part). With regards to your sub-issue, it would really help me help you if you include the entire stack trace through a pastebin link. Thanks
@dnnybnh can you explain how you fixed the issue (Missing .h files)? I'm running into the same thing.
In a freshly ejected Expo app I am only running pod install (no linking). I still have to manually add the RCTOneSignal.xcodeproj to the libraries group (which also does not exist, so I have manually added it).
Builds fail as soon as I add UIKit.framework, SystemConfiguration.framework and libRCTOneSignal.a to Link Binary with Libraries with missing RCTAnimationType.h or RCTDefines.h.
I have been following this guide a few times and I am still unsure what I am missing. As soon as I add the service extension these files are created NotificationService.h and NotificationService.m but later on it explains that if you are using cocoapods you need to update the NotificationServiceExtension.m file. Where does that one come from?
@peterkuiper At first I did the pod install base on the guide but later I just remove it from my pod file. Instead of the pod install way, I did react-native link react-native-onesignal and then do pod install.
My Link Binary with Libraries only have the UIKit and SystemConfig framework. This should remove the missing .h files.
Lastly, your NotificationService.h and .m file is fine and that is the same as NotificationService Extension.m. Other then these changes that I added everything should be the same base on the documentations.
PS. Make sure that you have all the ExpoKit required Notification method in your AppDelegate.m file. The reason for this is because ExpoKit recently upgraded their kit and the new kit causes app to crash when notification receive while you are in the app or opening the app through notification banner.
@dnnybnh Thanks. Not sure why the guide wants you to add libRCTOneSignal.a if it works without it. Maybe @Nightsd01 can elaborate on this.
Can you show me in the right direction for the Notification method? Not sure what it would look like, I just have to the default AppDelegate.m (fresh detach).
@peterkuiper First go into your pod file and locate the tag for ExpoKit and lmk what version that is in.
@dnnybnh 2.10.2 (SDK v32)
@peterkuiper So with 2.10.2 you will definitely crash on notification receive even if you managed to fix the rest. To fix this first change the tag from 2.10.2 to 2.10.4 and do pod deintegrate follow by pod install. pod deintegrate will clear your Pod files so that everything can be reinstall fresh (Optional). After that go into your AppDelegate.m and add the following between didFinishLaunchWithOptions and @end.
#pragma mark - Notifications
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token
{
[super application:application didRegisterForRemoteNotificationsWithDeviceToken:token];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
[super application:application didFailToRegisterForRemoteNotificationsWithError:err];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
[super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
The reason for this fix can be found at https://github.com/expo/expo/releases and the Expo Documentation https://docs.expo.io/versions/v32.0.0/expokit/expokit/ (Toward the section Upgrading ExpoKit)
Hope this helps!
@dnnybnh Thanks, this seems to fix the crash problems.
BTW, here is the link to the AppDelegate.m: https://github.com/expo/expo/blob/master/exponent-view-template/ios/exponent-view-template/AppDelegate.m and documentation: https://docs.expo.io/versions/v32.0.0/expokit/expokit/#ios-1.
Most helpful comment
@peterkuiper So with 2.10.2 you will definitely crash on notification receive even if you managed to fix the rest. To fix this first change the tag from
2.10.2to2.10.4and dopod deintegratefollow bypod install.pod deintegratewill clear your Pod files so that everything can be reinstall fresh (Optional). After that go into yourAppDelegate.mand add the following betweendidFinishLaunchWithOptionsand@end.The reason for this fix can be found at https://github.com/expo/expo/releases and the Expo Documentation https://docs.expo.io/versions/v32.0.0/expokit/expokit/ (Toward the section Upgrading ExpoKit)
Hope this helps!