How to use the @react-native-community/push-notification-ios.getInitialNotification function in @react-native-community/push-notification-ios

To help you get started, we’ve selected a few @react-native-community/push-notification-ios 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 OriginProtocol / origin / mobile / src / PushNotifications.js View on Github external
notification.finish(PushNotificationIOS.FetchResult.NoData)
        }
      },
      // Android only
      senderID: '162663374736',
      // iOS only
      permissions: DEFAULT_NOTIFICATION_PERMISSIONS,
      // Should the initial notification be popped automatically
      popInitialNotification: true,
      requestPermissions: Platform.OS !== 'ios'
    })

    if (Platform.os === 'ios') {
      // Get notifications that triggered an open of the app when the app was
      // completely closed
      PushNotificationIOS.getInitialNotification().then(notification => {
        if (notification) {
          // backgroundNotification is an instance of PushNotificationIOS, create
          // a notification object from it
          const notificationObj = {
            alert: this.state.backgroundNotification.getAlert(),
            data: this.state.backgroundNotification.getData()
          }
          // Pop the alert with option to redirect to WebView
          this.onNotification(notificationObj)
        }
      })

      // Get notifications that were triggered when the app was backgrounded
      PushNotificationIOS.addEventListener('notification', notification => {
        if (AppState.currentState === 'background') {
          // Save notification to state so it can be dealt with when the user
github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
_checkIfOpenedByCampaign(nextAppState) {
		// the app is turned from background to foreground
		if (
			this._currentState.match(/inactive|background/) &&
			nextAppState === 'active'
		) {
			PushNotificationIOS.getInitialNotification()
				.then(data => {
					if (data) {
						this.handleCampaignOpened(data);
					}
				})
				.catch(e => {
					logger.debug('Failed to get the initial notification.', e);
				});
		}
		this._currentState = nextAppState;
	}