How to use the react-native-push-notification.localNotification 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 blindsidenetworks / bigbluetutor-client / client / React-Native / app / BigBlueTutor.js View on Github external
onNotification: function(notification) {
        console.log(notification.notification.icon)
        PushNotification.localNotification({
          largeIcon: notification.notification.icon, // (optional) default: "ic_launcher"
          smallIcon: notification.notification.icon, // (optional) default: "ic_notification" with fallback for "ic_launcher"
          bigText: notification.notification.body, // (optional) default: "message" prop
          color: "blue", // (optional) default: system default
          vibrate: true, // (optional) default: true
          vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
          tag: 'some_tag', // (optional) add tag to message
          group: "group", // (optional) add group to message
          ongoing: false, // (optional) set whether this is an "ongoing" notification

          /* iOS only properties
          alertAction: // (optional) default: view
          category: // (optional) default: null
          userInfo: // (optional) default: null (object containing additional notification data)
          */
github keybase / client / shared / actions / platform-specific / index.native.tsx View on Github external
export async function saveAttachmentToCameraRoll(filePath: string, mimeType: string): Promise {
  const fileURL = 'file://' + filePath
  const saveType = mimeType.startsWith('video') ? 'video' : 'photo'
  const logPrefix = '[saveAttachmentToCameraRoll] '
  try {
    await requestPermissionsToWrite()
    logger.info(logPrefix + `Attempting to save as ${saveType}`)
    await CameraRoll.saveToCameraRoll(fileURL, saveType)
    logger.info(logPrefix + 'Success')
  } catch (e) {
    // This can fail if the user backgrounds too quickly, so throw up a local notification
    // just in case to get their attention.
    PushNotifications.localNotification({
      message: `Failed to save ${saveType} to camera roll`,
    })
    logger.debug(logPrefix + 'failed to save: ' + e)
    throw e
  } finally {
    require('rn-fetch-blob').default.fs.unlink(filePath)
  }
}
github keybase / client / shared / actions / platform-specific.native.js View on Github external
convID: ?string,
  badgeCount: ?number,
  myMsgID: ?number,
  soundName: ?string
) {
  // Dismiss any non-plaintext notifications for the same message ID
  if (isIOS) {
    PushNotificationIOS.getDeliveredNotifications(param => {
      PushNotificationIOS.removeDeliveredNotifications(
        param.filter(p => p.userInfo && p.userInfo.msgID === myMsgID).map(p => p.identifier)
      )
    })
  }

  logger.info(`Got push notification with soundName '${soundName || ''}'`)
  PushNotifications.localNotification({
    message: text,
    soundName,
    userInfo: {
      convID: convID,
      type: 'chat.newmessage',
    },
    number: badgeCount,
  })
}
github rastapasta / foodsharing / src / sagas / notifications.tsx View on Github external
//       alertBody: conversation.last_message
        //     })
        //   }
        // }
        if (inBackground)
          yield put({type: BACKGROUND_DONE})
      }

    // Bells update received in background must be via websocket -> notify user
      if (type === BELLS_SUCCESS && inBackground) {
        const bell = [payload[0] || {}] as any
            , title = translate(`bells.${bell.key}_title`, bell.payload)
            , message = translate(`bells.${bell.key}`, bell.payload)

        // Push a notification over the bridge!
        PushNotification.localNotification({
          title,
          message: message,
          userInfo: {
            bellId: bell.id
          }
        })
      }

      // Websocket Message received in background -> notify user
      if (type === WEBSOCKET_MESSAGE) {
        const { body, fs_name, fs_id, cid: conversationId } = payload
            , ownId = yield select(state => state.profile.id)

        // Continue if the user is the actual sender (ex on another device)
        if (fs_id == ownId)
          continue
github zo0r / react-native-push-notification / example / NotifService.js View on Github external
localNotif() {
    this.lastId++;
    PushNotification.localNotification({
      /* Android Only Properties */
      id: ''+this.lastId, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
      ticker: "My Notification Ticker", // (optional)
      autoCancel: true, // (optional) default: true
      largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
      smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"
      bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop
      subText: "This is a subText", // (optional) default: none
      color: "red", // (optional) default: system default
      vibrate: true, // (optional) default: true
      vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
      tag: 'some_tag', // (optional) add tag to message
      group: "group", // (optional) add group to message
      ongoing: false, // (optional) set whether this is an "ongoing" notification

      /* iOS only properties */
github ramsundark5 / stitchchat / app / services / BackgroundService.js View on Github external
_onNotification(notification) {
        PushNotification.localNotification({
            'userInfo': {},
            'message': notification.getMessage()
        });
    }
}
github MetaMask / metamask-mobile / app / core / TransactionsNotificationManager.js View on Github external
const pushData = {
				title,
				message,
				largeIcon: 'ic_notification',
				smallIcon: 'ic_notification_small'
			};

			const id = (data && data.message && data.message.transaction && data.message.transaction.id) || null;

			const extraData = { action: 'tx', id };
			if (Platform.OS === 'android') {
				pushData.tag = JSON.stringify(extraData);
			} else {
				pushData.userInfo = extraData;
			}
			PushNotification.localNotification(pushData);

			if (id) {
				this._transactionToView.push(id);
			}
		} else {
			showMessage(data);
		}
	}
github scorelab / Bassa-mobile / app / helpers / utils.js View on Github external
export const showPushNotification = (title, message, description) => {
  PushNotification.localNotification({
    bigText: description,
    color: theme.PRIMARY_STATUS_BAR_COLOR,
    vibration: 300,
    ongoing: false,
    title,
    message,
    soundName: 'default',
    number: '10',
  });
};