I don't know if I am missing anything but this would solve a pain I'm going through now.
For example: how could I add the notification type (i.e. say entryNotification or challengeNotification) when scheduling the notification?
Then I could access it in the data prop in onNotification: notification => {}
````
PushNotification.localNotificationSchedule({
/* Android Only Properties */
id: generatedId, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
// largeIcon: "@mipmap/ic_notif", // (optional) default: "ic_launcher"
smallIcon: "@mipmap/ic_notif", // (optional) default: "ic_notification" with fallback for "ic_launcher"
vibrate: true, // (optional) default: true
vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
priority: "high", // (optional) set notification priority, default: high
visibility: "private", // (optional) set notification visibility, default: private
importance: "high", // (optional) set notification importance, default: high
allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
ignoreInForeground: false, // (optional) if true, the notification will not be visible when the app is in the foreground (useful for parity with how iOS notifications appear)
/* iOS only properties */
alertAction: "view", // (optional) default: view
userInfo: {
id: generatedId,
}, // (optional) default: {} (using null throws a JSON value '<null>' error)
/* iOS and Android properties */
/* LOOKING FOR SOMETHING LIKE THIS */
data: {
notificationType: 'challengeNotification'
},
date: updatedDate,
repeatType: repeatType,
message: strings.DashboardComponent.challengeNotificationBody,
title: isCustomChallenge ? strings.DashboardComponent.customChallengeNotificationTitle : challengeObj.notificationTitle,
});
````
Hi @wmonecke
To achieve this, you can add a custom notification ID and save data in AsyncStorage.
In dev branch, scheduled notification trigger the application in background if needed.
When the notification is triggered / pressed you can read async storage with ID.
I was just looking to achieve the same, thanks for the workaround, but it is definitely cumbersome and hacky
@Dallas62 is there some technical limitation to implementing this functionality? firebase v5 did have it and we were using it extensively
@AlphaGolf33
in the end I ended up implementing the suggested solution by @Dallas62, it is cumbersome, but it doesn't look like this functionality will be implemented soon
Just be careful when generating the IDs (32 bit integer) because they will not fail on registering, but actually when the notification gets pushed and will only throw errors on the native logs
I just figured out that I can reach it by using the field userInfo 馃槄
Most helpful comment
I just figured out that I can reach it by using the field
userInfo馃槄