Reputation: 315
I'm updating a backend service that sends push notifications to iOS and Android devices through Firebase Cloud Messaging (FCM) HTTP APIs.
I noticed that we were using the legacy "HTTP Server Protocol" and now i'm trying to port our service to "FCM HTTP v1 API".
Sending a notification, in the previous protocol version responses, there were some error messages (see "Unregistered Device") to identify expired registration tokens. Now I receive a response with a "name" field containing a mysterious "message_id":
{ "name" : "projects/{project_id}/messages/{message_id}" }
I've even tried to send some notifications to very old tokens/devices without receiving any error.
I'm also considering to expire tokens on a time or app usage base.
Thanks in advance.
Upvotes: 4
Views: 2156
Reputation: 738
The doc says when the request was successful, the response contains an instance of the message.
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send
When the token is not available anymore we get a FileNotFoundException (in java) when we want to read the response. You can simple test this by deleting the app.
The "FCM HTTP v1 API" was announced at the last Firebase Dev Summit: https://firebase.googleblog.com/2017/10/whats-new-at-firebase-dev-summit-2017.html
Upvotes: 2