DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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 Author

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

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›