11

I'm trying to send a message to my device using a token I've gotten from a ticket saved in my PassWallet app in my Android device.

The device sends all the information required to update a pass using apple's wallet spec. However, I'm using FCM to send the notification and I'm getting this error: "The registration token is not a valid FCM registration token"

{
errorInfo: 
   { code: 'messaging/invalid-argument',
     message: 'The registration token is not a valid FCM registration token' },
  codePrefix: 'messaging' 
}

The code I'm using to send the message is the one from the Admin SDK sample:

var message = {
        token: device.pushToken
      };

      admin.messaging().send(message)
        .then((response) => {
          console.log('Successfully sent message:', response);
        })
        .catch((error) => {
          console.log('Error sending message:', error);
        });
  • I'm not sure if my message is incomplete and I need something else in the body.

  • If the token expired (Where you can verify this on Firebase).

  • If the message needs to specify whether is Android, iOS(APNS), etc...

This is the full stack trace:

Error: The registration token is not a valid FCM registration token
    at FirebaseMessagingError.FirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:39:28)
    at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:85:28)
    at new FirebaseMessagingError (/srv/node_modules/firebase-admin/lib/utils/error.js:241:16)
    at Function.FirebaseMessagingError.fromServerError (/srv/node_modules/firebase-admin/lib/utils/error.js:271:16)
    at FirebaseMessagingRequestHandler.handleHttpError (/srv/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:125:50)
    at /srv/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:113:23
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
  errorInfo: 
   { code: 'messaging/invalid-argument',
     message: 'The registration token is not a valid FCM registration token' },
  codePrefix: 'messaging' }
Dyan
  • 1,703
  • 4
  • 19
  • 26
  • 1
    I don't think PassWallet tokens are valid FCM tokens. To get a valid FCM token, see https://firebase.google.com/docs/cloud-messaging/ios/client#access_the_registration_token – Frank van Puffelen Jan 05 '19 at 00:54
  • Hi Frank, I'm not sure if what you are suggesting is send a message using apns or only generate new ones. The thing is passwallet is an app that I don't control but they use .pkpass files as in iOS wallet, is it possible for me to send notifications to this app through apn. – Dyan Jan 06 '19 at 02:53
  • 1
    To send messages through FCM you need an FCM token. And whatever you get from passwallet doesn't seem to be a valid FCM token. – Frank van Puffelen Jan 06 '19 at 04:06
  • Frank you are right about the token being the problem. I tried to send a message through postman and curl and I'm getting this error in the response: "error": "InvalidRegistration". And it's when I use the pushToken returned by the pkpass file to send the notification to that device. What I'm not sure is how to make that token a valid token for FCM or if I should use APNS instead – Dyan Jan 09 '19 at 17:02
  • @FrankvanPuffelen, based on this question https://stackoverflow.com/questions/37464706/firebase-fcm-get-tokens-for-old-ios-apns-tokens. I think that what I need to do is convert the APN token into a FCM token, but the batchImport requires an application and says is the app Bundle. The thing is I want the tokens to work no matter of the wallet app the user has in their phone. What should I do in this case? I'm getting this response "message_id": "0:1547059178561977%9ba8a687f9fd7ecd" from a fake application package which means I my poor knowledge that the message was sent – Dyan Jan 09 '19 at 18:55
  • I'm not sure how Wallet apps work. In general I think that you need to have an app ID to be able to send a notification to that app. But I admit that my knowledge on this is quite limited, so hope somebody else at this point might know more. It could also be that you should post a new question now explaining how you're trying to convert a Wallet token to an FCM token, and showing the API you're trying to call. – Frank van Puffelen Jan 09 '19 at 19:38
  • 1
    Frank you were right, after converting those tokens I was able to send messages sometimes then I started receiving some other error I posted another question with more details, thanks for your help. – Dyan Feb 01 '19 at 14:41
  • Hello @Dyan Im facing the same problem. How exactly did you solve the problem? Can I contact you on skype or something? Best regards, Dennis – kragekjaer Oct 04 '19 at 10:59

1 Answers1

-1

All information about the updated pass you should send to the Passwallet server. Please find the latest instructions here: https://github.com/Kwiket/passwallet

Passwallet Team

Iurii Perevertailo
  • 2,515
  • 2
  • 19
  • 12