examples/redux-firestore/src/utils/firebaseMessaging.js
function updateUserProfileWithToken(messagingToken) {
  const currentUserUid =
    firebase.auth().currentUser && firebase.auth().currentUser.uid
  if (!currentUserUid) {
    return Promise.resolve();
  }
  return firebase
    .firestore()
    .collection('users')
    .doc(currentUserUid)
    .update({
      messaging: {
        mostRecentToken: messagingToken,
        updatedAt: firebase.firestore.FieldValue.serverTimestamp()
      }
    })
}
function updateUserProfileWithToken(messagingToken) {
  const currentUserUid =
    firebase.auth().currentUser && firebase.auth().currentUser.uid
  if (!currentUserUid) {
    return Promise.resolve();
  }
  return firebase
    .firestore()
    .collection('users')
    .doc(currentUserUid)
    .update({
      messaging: {
        mostRecentToken: messagingToken,
        updatedAt: firebase.firestore.FieldValue.serverTimestamp()
      }
    })
}
function updateUserProfileWithToken ( messagingToken ) { const currentUserUid = firebase . auth ( ) . currentUser && firebase . auth ( ) . currentUser . uid if ( ! currentUserUid ) { return Promise . resolve ( ) ; } return firebase . firestore ( ) . collection ( 'users' ) . doc ( currentUserUid ) . update ( { messaging : { mostRecentToken : messagingToken , updatedAt : firebase . firestore . FieldValue . serverTimestamp ( ) } } ) }
Write FCM messagingToken to user profile
@param {String} messagingToken - Token to be written to user profile
Write FCM messagingToken to user profile