Firebase Cloud Messaging - How to validate Tokens?

Here is an example curl request that shows how to validate a token without actually having to send a message:

curl -H "Content-Type: application/json" -H "Authorization: key=$FCM_API_KEY" https://fcm.googleapis.com/fcm/send -d '{"registration_ids":["$FCMTOKEN"]}'

Example invalid response:

{"multicast_id":7452350602151058088,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}

Example valid response:

{"multicast_id":9133870199216310277,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1502817580237626%f590ddc2f9fd7ecd"}]}

I got this answer from google's firebase support team.


Actually there is a workaround, you can use dry_run = true

This parameter, when set to true, allows developers to test a request without actually sending a message.

firebase docs

if user unsubscribe, you have a response with NotRegistered but real sending won't be performed