Is it required to use new push token from user to send FCM notification after changing firebase app?

Please provide the following:

  1. SDK Version:
"expo": "^37.0.0",
"expo-constants": "~9.0.0",
"expo-permissions": "~8.1.0",
  1. Platforms(Android/iOS/web/all): Android

Hi,

Our team used Expo’s Push API to send notification. Everything works fine until the owner of the firebase app left and we had to create another firebase app.

Here’s what I’ve done:

  • create new firebase app
  • replace /google-services.json (in our source code) with the new one, downloaded from general settings of the new app.
  • use expo push:android:upload command to update FCM API key according to the official guide
  • publish new version of Android app

Now I receive “MismatchSenderId” error (example below) from Expo when trying to send notification from our server.

{
  "status": "error", 
  "message": "There was an unknown error with the FCM server. See this error's details for more information.", 
  "id": "xxxxxx", 
  "details": {
    "fault": "fcm", 
    "fcm": {
      "error": "MismatchSenderId"
    }, 
    "error": "ProviderError"
  }
}

We retrieve user’s notification permission through expo-permissions package when they logged in to our app. Then we issue a request to our back end to keep them so that we could use it when needed. Here’s how the code looks like:

// checkExpoToken.js
import askNotificationPermission from 'utils/permission'

// this function will be called when user logged in
export default () => {
  let token = await askNotificationPermission()
  if (token) {
    saveExpoToken({ token })  // sending token to our back end
  } else {
    // do some error handling
  }
}

// utils/permission.js
import { Notifications } from 'expo'
import * as Permissions from 'expo-permissions'

export default async function () {
  const { status: existingStatus } = await Permissions.getAsync(
    Permissions.NOTIFICATIONS
  )

  if (existingStatus === 'granted') {
    let token = await Notifications.getExpoPushTokenAsync()
    return token
  }

  const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS)

  const rejected = status !== 'granted'
  if (rejected) {
    return
  }

  let token = await Notifications.getExpoPushTokenAsync()
  return token
}

So my questions are:

  • Is it normal that I won’t be able to send notification to users if the token is asked on the old version of my app?
  • If so, what are the recommended steps to fix this? Should I delete the old token from server? How do I ask new token from users?

after changing /google-services.json, you need to submit a new APK or AAB, not just run expo publish. If you haven’t done that, then I think what’s happening here is that your app is hitting our servers with the old google-services config, while trying to use the new FCM server key

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.