Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Huawei Push Kit API - get Push Id from rest Api

I am trying to send notifications to my android app via HMS push with Rest api.

The system works, but I can't find an api to find the Push Id (Token).

{
    "validate_only": false,
    "message": {
        "notification": {
            "title": "Notifica simpatica",
            "body": "Io sono il body della notifica simpatica",
            "notify_icon": "https://res.vmallres.com/pimages//common/config/logo/SXppnESYv4K11DBxDFc2.png"
        },
        "data": "{'param1':'value1','param2':'value2'}",
        "android": {
            "collapse_key": -1,
            "urgency": "NORMAL",
            "category": "PLAY_VOICE",
            "ttl": "1448s",
            "fast_app_target": 1,
            "notification": {
                "click_action": {
                    "type": 1,
                    "intent": ""
                }
            }
        },
        "token": [
            "I NEED THIS"
        ]
    }
}

I have read about a push subscription api for get it but after two days i don't find nothing :(

Please help me! Thanks!

like image 938
Luca Parlapiano Avatar asked Jan 25 '23 05:01

Luca Parlapiano


2 Answers

PushToken can be received only from device. On device you should execute method for receiving it and then send this PushToken to your backend.

like image 104
mohax Avatar answered Feb 04 '23 04:02

mohax


mohax's answer is correct. I'd like to add a little more:

The pushtoken is obtained by using the API provided by the SDK after the client integrates the Push SDK. After obtaining the pushtoken, you need to send it to the server.

For details, pls kindly refer to this Docs.

like image 39
zhangxaochen Avatar answered Feb 04 '23 02:02

zhangxaochen