How to use the react-native-notifications.NotificationsAndroid.setNotificationOpenedListener function in react-native-notifications

To help you get started, we’ve selected a few react-native-notifications examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github demokratie-live / democracy-client / src / hocs / PushNotifications.js View on Github external
os: 'android',
                },
              });
              if (tokenSucceeded) {
                await AsyncStorage.setItem('push-token', deviceToken);
              }
            });
            NotificationsAndroid.refreshToken();

            // On Android, we allow for only one (global) listener per each event type.
            NotificationsAndroid.setNotificationReceivedListener(notification => {
              // console.log('PUSHLOG: setNotificationReceivedListener', notification);
              const notificationData = JSON.parse(notification.getData().payload);
              this.onNotificationReceivedForeground(notificationData);
            });
            NotificationsAndroid.setNotificationOpenedListener(notification => {
              // console.log('PUSHLOG: setNotificationOpenedListener', notification);
              const notificationData = JSON.parse(notification.getData().payload);
              this.onNotificationOpened(notificationData);
            });

            PendingNotifications.getInitialNotification().then(notifications => {
              // console.log('PUSHLOG: getInitialNotification', notifications);
              if (notifications) {
                notifications.data.forEach(notification => {
                  const notificationData = JSON.parse(notification.payload);
                  if (notification.opened) {
                    this.onNotificationOpened(notificationData);
                  } else {
                    this.handlePushData(notificationData);
                  }
                });
github zulip / zulip-mobile / src / utils / notifications.android.js View on Github external
export const addNotificationListener = (notificationHandler: (notification: Object) => void) => {
  NotificationsAndroid.setNotificationOpenedListener(notificationHandler);
};
github mattermost / mattermost-mobile / app / push_notifications / push_notifications.android.js View on Github external
NotificationsAndroid.setRegistrationTokenUpdateListener((deviceToken) => {
            this.deviceToken = deviceToken;
            if (this.onRegister) {
                this.onRegister({token: this.deviceToken});
            }
        });

        NotificationsAndroid.setNotificationReceivedListener((notification) => {
            if (notification) {
                const data = notification.getData();
                this.handleNotification(data, false);
            }
        });

        NotificationsAndroid.setNotificationOpenedListener((notification) => {
            if (notification) {
                const data = notification.getData();
                this.handleNotification(data, true);
            }
        });
    }
github RocketChat / Rocket.Chat.ReactNative / app / notifications / push / push.android.js View on Github external
constructor() {
		this.onRegister = null;
		this.onNotification = null;
		this.deviceToken = null;

		NotificationsAndroid.setRegistrationTokenUpdateListener((deviceToken) => {
			this.deviceToken = deviceToken;
		});

		NotificationsAndroid.setNotificationOpenedListener((notification) => {
			this.onNotification(notification);
		});
	}

react-native-notifications

Advanced Push Notifications (Silent, interactive notifications) for iOS & Android

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis