Search code examples
androidpush-notificationhuawei-mobile-serviceshuawei-push-notification

How to use the device token to send downlink message


After checking the official document, the device_token can not be used for hms_server to send downlink message. If i want to access hms_server, i must request another oauth2 token. Is it mean both the device_token and hms_server_token should be updated all the time, or choice only one like device_token to send downlink message?

URL: https://push-api.cloud.huawei.com/v1/appid/messages:send

Request Header: 
Authorization Bear token (need to request from hms_server, the device_token is only used for identify the address of device)

Solution

  • Both device_token and access_token are required. The device_token is obtained by the client and updated when the token changes. Changed scenario pls refer to this Docs.

    The access_token has a validity period. When the access_token is obtained, the validity period is returned. Generally, the validity period is one hour. The access_token is used within the validity period and does not need to be updated each time.