Is it possible to simulate a GCM receive from the adb shell / am command line? I'm getting an error

后端 未结 4 1398
难免孤独
难免孤独 2020-12-30 00:01

I\'m trying to simulate as if the device is receiving a GCM push message by using adb and the command line. I\'ve tried this command to broadcast a GCM intent:



        
4条回答
  •  忘掉有多难
    2020-12-30 00:46

    I suggest using command-line curl, as sending GCM pushes is as easy as calling some REST API. See sample shell script below:

    #!/bin/bash
    
    REGISTRATION_ID=YOUR_GCM_REGISTRATION_ID
    
    SERVER_KEY=YOUR_SERVER_KEY_FROM_GOOGLE_API_CONSOLE
    
    curl --header "Authorization: key=$SERVER_KEY" --header  Content-Type:"application/json"  https://android.googleapis.com/gcm/send  -d  "{ \"data\" : {\"foo\": \"bar\"}, \"registration_ids\":[\"$REGISTRATION_ID\"]  }"
    

提交回复
热议问题