I have an application which till now was using pure GCM integration for Android and pure APNS integration for iOS. Client application registers for Push Notification service and send back registration token to my server, which I can use to send targeted messages. This is existing system. Now I have imported my GCM project into Firebase, and Android and iOS application configs are added to project. This way, I can integrate Firebase SDK in next version of my apps and use enhanced notification capabilities.
Next step was to change backend implementation and use Firebase console to send notifications. Instance ID batchImport API was really straight forward, I took APNS token from my database, and API returned the registration token. This I used in Firebase to single device and notification was triggered. I could even subscribe this token to the topic I wished.
But now I am trying to use Android GCM registration token in Firebase console, no error, but notification is not triggered. When I tried to subscribe for topic using batchAdd, I received following output with HTTP response 400.
{
"error": "InvalidTokenVersion"
}
I have not found any documentation on this error, and how to correct same. The token I used is perfectly valid since I can trigger notifications using same via old GCM server code.
GCM token looks like this
APA91bE_uLJ4dyXXXXX_Tn2qbCWgzCW4GR6t78_z-Up_gSdX7tekiSKWmXXXXXwSainHPTz5hQ6XM8F-j3XLKZuIUgNM84v_XXXXXeJ1pX_YBTn5OUNnZte2uSSisLBqQwCPGYXXXXXX
New token generated after importing APNS tokens, there is difference in token length, nothing else I can find.
cUt0RhCYXXX:APA91bG5JraXXXXX1M2lFHjzw_XXXXXg2qGQZ_iUDjoaXXXXXw4vv0JND24-4hj5ppvsXXXXXV4WWgNsurteN_nXXXXXi3SfzjBXZt5X00PXzhb3XXXXXlf_WDVxoIvkXXXXXRd2Rw1
GCM library included 2 different APIs to generate GCM tokens:
GoogleCloudMessaging.register() // Deprecated in 2015
InstanceID.getToken()
Unfortunately tokens generated with the first API are not supported by the Topics API (both in GCM and FCM).
BathAdd
API is part of the InstanceId / Topics API.
I understand this is not ideal, unfortunately the best option is to update the application to use GCM InstanceId.getToken() or FCM.