How to use the react-native-notifications.NotificationsAndroid.refreshToken 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.

github demokratie-live / democracy-client / src / hocs / PushNotifications.js View on Github external
LISTENERS_ADDED = true;
            NotificationsAndroid.setRegistrationTokenUpdateListener(async deviceToken => {
              // console.log('PUSHLOG: setRegistrationTokenUpdateListener', deviceToken);
              // TODO: Send the token to my server so it could send back push notifications...
              const tokenSucceeded = await client.mutate({
                mutation: ADD_TOKEN,
                variables: {
                  token: deviceToken,
                  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) {
github zulip / zulip-mobile / src / utils / notifications.android.js View on Github external
export const refreshNotificationToken = () => {
  NotificationsAndroid.refreshToken();
};
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();
	}
}