Reputation: 33
I've gone through "How to implement push token in android" part 1 and part 2. part 1 is saying get the push token using HMS sdk and send it to server and second part is only using app id and app secret written inside AppGallery Connect account. nowhere it is using push token which we got from hms sdk through android device. so My question is How HMS push server will decide on which device it has to send the particular push message? how could app server use push token to send push notification to a specific device?
Upvotes: 1
Views: 738
Reputation: 34047
First, your app obtains a unique push token through the HMS SDK. Then, your server calls an API and passes the token to the API. Finally, the push server finds the specified device based on the push token and sends messages.
For more details, you could refer to this Docs.
Upvotes: 0
Reputation: 2035
General speaking, Push notification for Huawei HMS is the service from Huawei Cloud Messaging. For Huawei Cloud Messaging, the developer’s server sends the message to Huawei's Push server, including a token that identifies the device. In fact the token is unique for your app running on a device. Obviously the channel is secure and your server need credentials (certificate). Huawei push delivery has several ways:
Topic-based message sending(essentially it’s based on token). For detail info, pls refer to : https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-topic-based-sending-0000001050040114
HTTPS REST API. You can use https API to send message, subscribe a topic, etc. For more info, pls refer to : https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/https-send-api-0000001050986197
Audience-based message sending. For audience definition and information, pls refer to : https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/audience-analysis-0000001050705124 https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-enhanced-audiencesend-0000001154278143
Upvotes: 0
Reputation: 4585
When you try to receive accessToken on device, device makes request to HMS server. If request is successful - HMS server generates unique token for this device and sends this token to device. Then, device sends token to your server. So your server, your device and HMS server have token. Now you can send request from your server to HMS server. And HMS server resends message from your server to device. (device opens socket connection to HMS server, passing token. If HMS server receives message - it transfers it to device via this socket connection)
Upvotes: 1