Ad

FCM Error In IOS : The Caller Does Not Have Permission?

I am using Firebase node Admin API to send push notification to Android and IOs devices. Android is working fine but in IOS, I can generate FCM token but when I send push notification to IOS token from the node js (firebase admin code), I am getting the below error:

 Error sending message: { Error: The caller does not have permission
    at FirebaseMessagingError.FirebaseError [as constructor] (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:39:28)
    at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:85:28)
    at new FirebaseMessagingError (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:250:16)
    at Function.FirebaseMessagingError.fromServerError (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:280:16)
    at FirebaseMessagingRequestHandler.handleHttpError (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:125:50)
    at /Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:113:23
    at process._tickCallback (internal/process/next_tick.js:68:7)
  errorInfo:
   { code: 'messaging/mismatched-credential',
     message: 'The caller does not have permission' },
  codePrefix: 'messaging' }

I am using react native for Android and IOS

Ad

Answer

As per your error info

code: 'messaging/mismatched-credential'

Firebase official documentation says :

The credential used to authenticate this SDK does not have permission to send messages to the device corresponding to the provided registration token. Make sure the credential and registration token both belong to the same Firebase project. See Add Firebase to your app for documentation on how to authenticate the Admin SDKs.

You probably configured Android correctly but you missed some small thing for iOS. Follow this link to setup iOS client :)

Ad
source: stackoverflow.com
Ad