How to use the react-native-push-notification.configure function in react-native-push-notification

To help you get started, we’ve selected a few react-native-push-notification 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 mikelambert / dancedeets-monorepo / js / notifications / setup.js View on Github external
function init() {
  const intl = constructIntl();
  globalHandler = new Handler(null, intl);
  let lastTokenRegistration = null;

  PushNotification.configure({
      onRegister: async function (tokenRegistration: TokenRegistration) {
        // Don't re-process if we've already already recorded this token
        if (lastTokenRegistration == tokenRegistration.token) {
          return;
        }
        lastTokenRegistration = tokenRegistration.token;
        setupMixpanelToken(tokenRegistration);
        await saveToken(tokenRegistration);
      },

      onNotification: globalHandler.receivedNotification,

      // ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
      senderID: '911140565156',

      // IOS ONLY (optional): default: all - Permissions to register.
github infinitered / ChainReactApp2017 / App / Config / PushConfig.js View on Github external
configure: (dispatch) => {
    // https://github.com/zo0r/react-native-push-notification
    PushNotification.configure({

      // (optional) Called when Token is generated (iOS and Android)
      onRegister: (token) => {
        if (__DEV__) console.log('TOKEN:', token)
      },

      // (required) Called when a remote or local notification is opened or received
      onNotification: (notification) => {
        dispatch(NotificationActions.addNotification(notification.message))
      },

      // ANDROID ONLY: (optional) GCM Sender ID.
      senderID: 'YOUR GCM SENDER ID',

      // IOS ONLY (optional): default: all - Permissions to register.
      permissions: {
github open-app / app-hub-mobile / src / utils / pushNotificationConfig.js View on Github external
(function() {
  // Register all the valid actions for notifications here and add the action handler for each action
  PushNotification.registerNotificationActions([ i18n.t('notificationAction') ])
  DeviceEventEmitter.addListener('notificationActionReceived', (action) => {
    console.log ('Notification action received: ' + action)
    const info = JSON.parse(action.dataJSON)
    if (info.action == i18n.t('notificationAction')) {
      if (Platform.OS === 'android') BackHandler.exitApp()
      else RNExitApp.exitApp()
    }
  })
})()

const configure = PushNotification.configure({
  // (optional) Called when Token is generated (iOS and Android)
  onRegister: (token) => {
    console.log( 'TOKEN:', token )
  },
  // (required) Called when a remote or local notification is opened or received
  onNotification: (notification) => {
    console.log( 'NOTIFICATION:', notification )
    // process the notification
    // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
    notification.finish(PushNotificationIOS.FetchResult.NoData)
  },
  // ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
  senderID: "YOUR GCM SENDER ID",
  // IOS ONLY (optional): default: all - Permissions to register.
  permissions: {
    alert: true,
github OriginProtocol / origin / mobile / src / PushNotifications.js View on Github external
async componentDidMount() {
    // Add an event listener to log registration errors in development
    if (__DEV__) {
      PushNotificationIOS.addEventListener('registrationError', error =>
        console.warn(error)
      )
    }

    PushNotification.configure({
      // Called when Token is generated (iOS and Android) (optional)
      onRegister: deviceToken => {
        // Save the device token into redux for later use with other accounts
        this.props.setDeviceToken(deviceToken['token'])
      },
      // Called when a remote or local notification is opened or received
      onNotification: notification => {
        this.onNotification(notification)
        // https://facebook.github.io/react-native/docs/pushnotificationios.html
        if (Platform.OS === 'ios') {
          notification.finish(PushNotificationIOS.FetchResult.NoData)
        }
      },
      // Android only
      senderID: '162663374736',
      // iOS only
github rdev / now-mobile / src / screens / Main.js View on Github external
componentDidMount = async () => {
		setUpBackgroundTask();
		PushNotification.configure({
			onNotification: (notification) => {
				if (notification.userInteraction) {
					this.titleSlider.snapToItem(4);
					this.viewSlider.snapToItem(4);
				}
				notification.finish(PushNotificationIOS.FetchResult.NoData);
			},
			requestPermissions: true,
		});
		// We only need to do some things on first ever render
		const fromSplash = this.props.navigation.getParam('fromSplash');
		if (!isAndroid) {
			const Spotlight = require('../extensions/spotlight');
			Spotlight.addListener(this.handleSpotlightClick);
			const id = await Spotlight.handleAppOpen();
			if (fromSplash && id) {
github blindsidenetworks / bigbluetutor-client / client / React-Native / app / BigBlueTutor.js View on Github external
configurePush() {
    PushNotification.configure({
      // (optional) Called when Token is generated (iOS and Android)
      onRegister: function(token) {
        var ds
        var profileRecord
        if (this.props) {
          if(this.props.ds) {
            ds = this.props.ds
          }
          if(this.props.profileRecord) {
            profileRecord = this.props.profileRecord
          }
        }
        if (this.state) {
          if (this.state.ds) {
            ds = this.state.ds
          }
github Backendless / JS-SDK / examples / messaging-service / push-notification / react-native / app.js View on Github external
Text,
  View
} from 'react-native';

import PushNotification from 'react-native-push-notification';

import DeviceInfo from 'react-native-device-info';

import Backendless from 'backendless';

const APP_ID = 'YOUR_APPLICATION_ID';
const APP_KEY = 'YOUR_APPLICATION_KEY';

Backendless.initApp(APP_ID, APP_KEY);

PushNotification.configure({

  // (optional) Called when Token is generated (iOS and Android)
  onRegister: function(device) {
    Backendless.setupDevice({
      uuid    : DeviceInfo.getUniqueID(),
      platform: device.os,
      version : DeviceInfo.getSystemVersion()
    });

    Backendless.Messaging.registerDevice(device.token).then(
      function() {
        alert("Registration done");
      },
      function() {
        alert("Oops. Something went wrong");
      }
github rastapasta / foodsharing / src / sagas / notifications.tsx View on Github external
export default function* notificationSaga() {
  // Wait for a successful login
  yield take(LOGIN_SUCCESS)

  // Seupt the native Push Notification service
  yield PushNotification.configure({

    // Listen for interactions with a displayed notification
    onNotification: notification => {
      store.dispatch({type: NOTIFICATION_CLICKED})

      // If we were able to set some data along with the notification (iOS), handle it!
      const { data } = notification
      if (data && data.conversationId)
        Actions.conversation({conversationId: data.conversationId})
      else if (data && data.bellId)
        Actions.bells()
      else
        Actions.conversations()

      // If we're on iOS, trigger the expected callback
      if (Platform.OS === 'ios')
github crownstone / CrownstoneApp / js / backgroundProcesses / NotificationHandler.ts View on Github external
configure() {
    LOG.notifications("NotificationHandler: Configuring Push");
    PushNotification.configure({
      // (optional) Called when Token is generated (iOS and Android)
      onRegister: (tokenData) => {
        this.requesting = false;
        this.notificationPermissionGranted = true;
        core.store.dispatch({
          type: "SET_NOTIFICATION_TOKEN",
          data: {
            notificationToken: tokenData.token
          }
        });
        LOG.notifications("NotificationHandler: Got notification token!", tokenData, tokenData.token);

        let state = core.store.getState();
        let deviceId = Util.data.getCurrentDeviceId(state);
        if (!deviceId) { return LOGe.notifications("NotificationHandler: NO DEVICE CONFIGURED"); }
github abudaan / push-notification-server / client / pushtest2 / index.ios.js View on Github external
componentDidMount() {
    this.state.messages.push('mount\n')
    this.setState(this.state)
    PushNotification.configure({
      onNotification: this.handleNotification.bind(this),
      onRegister: this.handleRegister.bind(this),
      permissions: {
        alert: true,
        badge: true,
        sound: true
      },
      //senderID not necessary for iOS
    })
  }