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
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 :)
In my case from what I could figure out, push notifications worked on android but iOS for some reason gave me this exact same error.
What I did was:
GoogleService-Info.plist
from the firebase console making sure it's the one for iOS device copy items if needed
option was checked
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.