How to use the react-native-notifications.PendingNotifications.getInitialNotification 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
});
            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);
                  }
                });
              }
            });
            // .catch(err => console.error('getInitialNotifiation() failed', err));
          }
          break;
        default:
github mattermost / mattermost-mobile / app / push_notifications / push_notifications.android.js View on Github external
configure(options) {
        this.onRegister = options.onRegister;
        this.onNotification = options.onNotification;
        this.onReply = options.onReply;

        if (this.onRegister && this.deviceToken) {
            this.onRegister({token: this.deviceToken});
        }

        if (options.popInitialNotification) {
            PendingNotifications.getInitialNotification().
                then((notification) => {
                    if (notification) {
                        const data = notification.getData();
                        if (data) {
                            ephemeralStore.appStartedFromPushNotification = true;
                            this.handleNotification(data, true);
                        }
                    }
                }).
                catch((err) => {
                    console.log('Android getInitialNotifiation() failed', err); //eslint-disable-line no-console
                });
        }
    }
github RocketChat / Rocket.Chat.ReactNative / app / notifications / push / push.android.js View on Github external
configure(params) {
		this.onRegister = params.onRegister;
		this.onNotification = params.onNotification;
		NotificationsAndroid.refreshToken();
		return PendingNotifications.getInitialNotification();
	}
}
github zulip / zulip-mobile / src / utils / notifications.android.js View on Github external
export const handleInitialNotification = async (dispatch: Dispatch, usersById: UserIdMap) => {
  const data = await PendingNotifications.getInitialNotification();
  handlePendingNotifications(data, dispatch, usersById);
};

react-native-notifications

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

MIT
Latest version published 7 months ago

Package Health Score

72 / 100
Full package analysis