I am trying to open specific activity when user click on notification

Viewed 33

I want to open specific activity on Recatnative app when user click on notification takes the user to specific screen according to the notification sent.

export default class AppextendsComponent {
componentWillmount() {
// add listeners to listen to different events
OneSignal.addEventListener('received', this.onReceived);
OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('registered', this.onRegistered);
OneSignal.addEventListener('ids', this.onIds);
}
componentWillUnmount() {
// remove listeners when unmount
OneSignal.removeEventListener('received', this.onReceived);
OneSignal.removeEventListener('opened', this.onOpened);
OneSignal.removeEventListener('registered', this.onRegistered);
OneSignal.removeEventListener('ids', this.onIds);
}`enter code here`
onReceived(notification) {
console.log("Received Notification: ", notification);
}
onOpened(openResult) {
//perform logging
console.log("Opened Notification");
console.log('Message: ', openResult.notification.payload.body);
console.log('Data: ', openResult.notification.payload.additionalData);
console.log('isActive: ', openResult.notification.isAppInFocus);
console.log('openResult: ', openResult);
}
onRegistered(notifData) {
// triggered when device is registered for using push notification
console.log("Device had been registered for push notifications!", notifData);
}
onIds(device) {
console.log('Device info: ', device);
}
}
0 Answers
Related