Question:
I pass a key/value data in the push notifications using the Android/iOS Custom data field from the Pushwoosh Control Panel. How can I get it from the push notification payload for further handling in my app?
Answer:
First of all, it is necessary to emphasise the fact that the custom data is stored in the "u" key of the push notification payload. Here you can find detailed information about available payload keys:
Push Notification payload keys
To get this key from the push notification payload, use the following method:
DeviceEventEmitter.addListener('pushReceived', (e: Event) => {
const customData = JSON.parse(e.u);
console.warn("customData: " + JSON.stringify(customData));
});
In the example above, it is simply converted to a string and printed in the console.
Comments
0 comments
Please sign in to leave a comment.