Tabnine Logo For Javascript
@react-native-firebase/messaging
Code IndexAdd Tabnine to your IDE (free)

How to use @react-native-firebase/messaging

Best JavaScript code snippets using @react-native-firebase/messaging(Showing top 12 results out of 1,395)

origin: riantosm/firebase-push-notification

// when the app is running, but in the backgroud
  messaging().onNotificationOpenedApp(remoteMessage => {
   console.log(
    '[FCMService] onNotificationOpenedApp Notification caused app to open',
   );
   if (remoteMessage) {
    const notification = remoteMessage.notification;
    onOpenNotification(notification);
    // this.removeDeliveredNotification(notification.notificationId)
   }
  });
origin: riantosm/firebase-push-notification

messaging()
   .deleteToken()
   .catch(error => {
    console.log('[FCMService] delete token error ', error);
   });
origin: riantosm/firebase-push-notification

messaging()
   .requestPermission()
   .then(() => {
    this.getToken(onRegister);
   })
   .catch(error => {
    console.log('[FCMService] request permission rejected ', error);
   });
origin: riantosm/firebase-push-notification

messaging().onMessage(async remoteMessage => {
   console.log('[FCMService] a new FCM message arrived!', remoteMessage);
   if (remoteMessage) {
    let notification = null;
    if (Platform.OS === 'ios') {
     notification = remoteMessage.data.notification;
    } else {
     notification = remoteMessage.notification;
    }
    onNotification(notification);
   }
  })
origin: tuan072090/rn-example

const unsubscribe = messaging().onMessage(async remoteMessage => {
  console.warn("message when app opening...", remoteMessage)
});
messaging().onNotificationOpenedApp(remoteMessage => {
  console.warn(
    'app open from background state........:', remoteMessage,
  .getInitialNotification()
  .then(remoteMessage => {
    if (remoteMessage) {
origin: riantosm/firebase-push-notification

// when the app is opened from a quit state.
  messaging()
   .getInitialNotification()
   .then(remoteMessage => {
    console.log(
     '[FCMService] getInitialNotification Notification caused app to open',
    );
    if (remoteMessage) {
     const notification = remoteMessage.notification;
     onOpenNotification(notification);
     // this.removeDeliveredNotification(notification.notificationId)
    }
   });
origin: tuan072090/rn-example

return messaging().onTokenRefresh(token => {
  console.log('new token', token);
});
const authorizationStatus = await messaging().requestPermission();
console.log("authorizationStatus.....", authorizationStatus)
if (authorizationStatus) {
const deviceRemote = await messaging().registerDeviceForRemoteMessages();
const token = await messaging().getToken();
console.log("fcm token.......", token);
origin: riantosm/firebase-push-notification

// triggered when have new token
  messaging().onTokenRefresh(fcmToken => {
   console.log('[FCMService] new token refresg: ', fcmToken);
   onRegister(fcmToken);
  });
origin: riantosm/firebase-push-notification

messaging()
   .getToken()
   .then(fcmToken => {
    if (fcmToken) {
     onRegister(fcmToken);
     messaging().subscribeToTopic('all');
    } else {
     console.log('[FCMService] user does not have a device token');
    }
   })
   .catch(error => {
    console.log('[FCMService] getToken rejected ', error);
   });
origin: riantosm/firebase-push-notification

messaging()
   .hasPermission()
   .then(enabled => {
    if (enabled) {
     // user has permissions
     this.getToken(onRegister);
    } else {
     // user doens't have permission
     this.requestPermission(onRegister);
    }
   })
   .catch(error => {
    console.log('[FCMService] Permission rejected ', error);
   });
origin: tuan072090/rn-example

// Register background handler
messaging().setBackgroundMessageHandler(async remoteMessage => {
  console.log('handled in the background when app close and kill...', remoteMessage);
});
origin: riantosm/firebase-push-notification

messaging().setBackgroundMessageHandler(async remoteMessage => {
 console.log('Message handled in the background!', remoteMessage);
});
@react-native-firebase/messaging(npm)

Most used @react-native-firebase/messaging functions

  • Module.getInitialNotification
  • Module.getToken
  • Module.onMessage
  • Module.onNotificationOpenedApp
  • Module.onTokenRefresh
  • Module.setBackgroundMessageHandler,
  • Module.deleteToken,
  • Module.hasPermission,
  • Module.registerDeviceForRemoteMessages,
  • Module.subscribeToTopic,
  • RemoteMessage.data,
  • RemoteMessage.notification,
  • notification

Popular in JavaScript

  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • readable-stream
    Streams3, a user-land copy of the stream library from Node.js
  • postcss
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • minimist
    parse argument options
  • aws-sdk
    AWS SDK for JavaScript
  • commander
    the complete solution for node.js command-line programs
  • lodash
    Lodash modular utilities.
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now