I am developing two iOS projects. Both are different firebase projects (Project-A and Project-B). Both enabled push notifications. I am sending the notification using cloud functions (Project-B). I am generating a token in Project-A using Project-B's messaging Id and saving that in the database(Project-B). Now by using that token I am trying to send a notification to that device token. But when I try to do that I am facing some error in the cloud functions like below.
#Cloud function error on Project-B
{ code: 'messaging/invalid-registration-token',
{ Error: Invalid registration token provided. Make sure it matches the registration token the
client app receives from registering with FCM.
message: at FirebaseMessagingError.FirebaseError [as constructor]
(/workspace/node_modules/firebase-admin/lib/utils/error.js:42:28)
'Invalid registration token provided. Make sure it matches the registration token the client
app receives from registering with FCM.'
},
at FirebaseMessagingError.PrefixedFirebaseError [as constructor]
(/workspace/node_modules/firebase-admin/lib/utils/error.js:88:28)
codePrefix: 'messaging'
}
#Device token generation in Project-A using Project-B's messaging Id on client-side
let secondAppSenderIdString = "123456******"
InstanceID.instanceID().token(withAuthorizedEntity: secondAppSenderIdString, scope: fcmToken,
options: ["apns_token": fcmToken], handler: { (token, error) in
// handle token and error
guard error == nil else{
print("Found an error! (error!.localizedDescription)")
return
}
print(" didReceiveRegistrationToken is token",token!)
currentdeyaPayToken = token!
})
I have done the same on Android also. In android, there is no issue. But in iOS I am facing those errors. Do I need to do any something extra or did I do any wrong?
question from:https://stackoverflow.com/questions/65661761/ios-cloud-messaging-between-two-different-firebase-projects-push-notification