DEV Community

Kay Gosho
Kay Gosho

Posted on

Getting initial notification in React Native

Getting initial notification in React Native seems not to work RN 0.59.x.

https://github.com/react-native-community/react-native-push-notification-ios/issues/24

I'll try to find a solution. current possible solutions in my mind are:

1. Save userData in didReceiveRemoteNotification

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];

  // save userData to somewhere
}

2. Build a native module

Accessing userData via Native modules. It seems that we can access to userData after app launch.

https://github.com/react-native-community/react-native-push-notification-ios/blob/master/js/index.js#L346

https://github.com/react-native-community/react-native-push-notification-ios/blob/3cf608c83dac011634429fbebd7d55a7c6ae8c13/ios/RNCPushNotificationIOS.m#L407

UIApplicationLaunchOptionsRemoteNotificationKey not getting userinfo - https://stackoverflow.com/questions/30297594/uiapplicationlaunchoptionsremotenotificationkey-not-getting-userinfo

Top comments (1)

Collapse
 
acro5piano profile image
Kay Gosho

I solved. Our marketing tool saves data as deeplink, so notification couldn't get the data