How to use the react-native-notifications.requestPermissions 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 JetBrains / youtrack-mobile / src / components / push-notifications / push-notifications.ios.js View on Github external
resolve();
      } catch (err) {
        reject(err);
      }
    }
    NotificationsIOS.addEventListener('remoteNotificationsRegistered', onRegister);

    async function onRegistrationError(e) {
      NotificationsIOS.removeEventListener('remoteNotificationsRegistrationFailed', onRegistrationError);
      log.info('PUSH: registration error', e);
      reject(e);
    }
    NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', onRegistrationError);

    // $FlowFixMe: error in type annotations of library
    NotificationsIOS.requestPermissions();
  });
}
github zulip / zulip-mobile / src / notification / index.js View on Github external
// though I haven't successfully traced all the steps there:
    //   https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623022-application?language=objc
    // which certainly in the wix case leads to a call to this:
    //   https://developer.apple.com/documentation/uikit/uiapplication/1623078-registerforremotenotifications
    // which "initiate[s] the registration process with [APNs]".  Then the
    // methods that calls on success/failure in turn are implemented to send
    // an event with name `remoteNotificationsRegistered` etc., in both the
    // wix and RN-upstream case.  (Though NB in the *failure* case, the
    // event names differ!  wix has s/Error/Failed/ vs. upstream; also
    // upstream has singular for failure although plural for success, ouch.)
    //
    // In short, this kicks off a sequence: permissions -> "register" ->
    // send event we already have a global listener for.  And the first two
    // steps satisfy the stern warnings in Apple's docs (at the above links)
    // to request permissions first, then "register".
    NotificationsIOS.requestPermissions();
  } else {
    // On Android, we do this at application startup.
  }
};
github JetBrains / youtrack-mobile / src / components / push-notifications / push-notifications.ios.js View on Github external
export function initializePushNotifications() {
  // $FlowFixMe: error in type annotations of library
  NotificationsIOS.requestPermissions();
  NotificationsIOS.consumeBackgroundQueue();
}
github CMP-Studio / DawnChorus / app / actors / notifications.ios.js View on Github external
async requestPermissions() {
    try {
      NotificationsIOS.requestPermissions([this.alarmActions]);
      await NativeModules.CMSiOSNotificationPermissionsManager.requestPermissions();
    } catch (e) {
      console.log(e);
    }
  }
}
github RocketChat / Rocket.Chat.ReactNative / app / notifications / push / push.ios.js View on Github external
});

		NotificationsIOS.addEventListener('notificationOpened', (notification, completion) => {
			const { background } = reduxStore.getState().app;
			if (background) {
				this.onNotification(notification);
			}
			completion();
		});

		const actions = [];
		actions.push(new NotificationCategory({
			identifier: 'MESSAGE',
			actions: [replyAction]
		}));
		NotificationsIOS.requestPermissions(actions);
	}
github mattermost / mattermost-mobile / app / push_notifications / push_notifications.ios.js View on Github external
requestPermissions = (permissions) => {
        NotificationsIOS.requestPermissions(permissions);
    };
github demokratie-live / democracy-client / src / hocs / PushNotifications.js View on Github external
constructor(props) {
      super(props);
      switch (Platform.OS) {
        case 'ios':
          NotificationsIOS.addEventListener('remoteNotificationsRegistered', this.onPushRegistered);
          NotificationsIOS.addEventListener(
            'remoteNotificationsRegistrationFailed',
            this.onPushRegistrationFailed,
          );
          if (!DeviceInfo.isEmulator()) {
            NotificationsIOS.requestPermissions();
          }

          NotificationsIOS.addEventListener('notificationReceivedForeground', notification => {
            this.onNotificationReceivedForeground(notification.getData());
          });
          NotificationsIOS.addEventListener('notificationReceivedBackground', notification => {
            this.onNotificationReceivedBackground(notification.getData());
          });
          NotificationsIOS.addEventListener('notificationOpened', notification => {
            this.onNotificationOpened(notification.getData());
          });
          break;
        case 'android':
          if (!LISTENERS_ADDED) {
            LISTENERS_ADDED = true;
            NotificationsAndroid.setRegistrationTokenUpdateListener(async deviceToken => {

react-native-notifications

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

MIT
Latest version published 7 months ago

Package Health Score

70 / 100
Full package analysis