-->

How to tell if GCM token is valid, without sending

2020-08-01 18:46发布

问题:

Is there a way to tell when a GCM token is no longer valid, without actually attempting to send a notification and receive an error?

Thanks.

回答1:

You can do this by using the dry run feature provided by the google.

When sending request for a notification from your web server to GCM servers you can add dry_run key to be true

This parameter allows developers to test a request without actually sending a message. The default value is false, and it must be a JSON boolean.

If the Notification key is invalid it would give the corresponding http response of the request