谷歌gcm raw_data(有效载荷加密),未收到推送事件 [英] google gcm raw_data (payload encryption) , push event not received

查看:213
本文介绍了谷歌gcm raw_data(有效载荷加密),未收到推送事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b $ ol <$>
  • 没有有效载荷加密的第一种情况
  • >

    在这种情况下,我收到服务人员的推送事件:


    • 要求是:




      curl -s --headerAuthorization:key = MY_KEY--headerContent-Type:application / json--headerTTL:86400https://android.googleapis.com/gcm/send -d{\ registration_ids\ :[\ elmll0-ynBY:APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\ ],\ delay_while_idle\ :假,\ collapse_key\ :\ hipush-notification\,\\ \\time_to_live \:86400}




    • Google回应如下:


      $ b $ p $ {multicast_id:5772871775830750210,成功 :1,失败ure:0,canonical_ids:0,results:[{message_id:0:1465913797471899%f4d428f3bf364ddd}]}




      1. 第二项测试,加密raw_data

      我从来没有收到推送事件:
      - 请求是:

        curl -s --headerAuthorization:key = MY_KEY --header 内容类型:应用程序/ JSON --header TTL:86400 --header 加密:盐= KYw1fpU-Dg4w1qFcrPY3rQ --header 加密密钥:DH = BOwb4OiwboYRrbhhXh056xFZ8pk8kfQR27Gmu3EdYPG9DkLoKRqA_d4Z_TbT2VYMfHVkGS-dY45rZ8tAimqSWrk  - headerContent-Encoding:aesgcmhttps://android.googleapis.com/gcm/send --headerContent-Length:363-d{\registration_ids \:[\elmll0-ynBY :APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\ ],\ delay_while_idle\ :假,\ collapse_key\ :\ hipush-notification\,\ time_to_live\:864 00,\raw_data \:\rXJHqmhxmTde + 297wtb3Tpj5Lq5C8cd2eYW5qTBoC3huGVTOPog6 + I2Y6wQEYqP1QIAvUA0NFtYC7Zr\ / iCR1sGcu\}




      • Google回应如下:




        {multicast_id:7840093467258640262,success:1,failure:0,canonical_ids:0,results:[{message_id:0:1465913901129815%f4d428f3bf364ddd} ]} 

      成功时我得到了同样的回应。



      最好的问候,

      最好的问候, / p>

      Mehdi

      解决方案

      您正在使用哪种语言?您可以在这里使用其中一个库 https://github.com/web-push-libs (Node.js,PHP,Python,Java当前支持),它们已经解决了您的问题。


      I need some help because i never receive push event in my serviceworker after payload encryption.

      1. First case without payload encrypted

      In this case, I receive push event in service worker:

      • Request is :

      curl -s --header "Authorization: key=MY_KEY" --header "Content-Type: application/json" --header "TTL:86400" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"elmll0-ynBY:APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\"],\"delay_while_idle\":false,\"collapse_key\":\"hipush-notification\",\"time_to_live\":86400}"
      

      • Google response is :

      {"multicast_id":5772871775830750210,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1465913797471899%f4d428f3bf364ddd"}]}
      

      1. Second test, with encrypted raw_data

      I never receive push event: - Request is :

      curl -s --header "Authorization: key=MY_KEY" --header "Content-Type: application/json" --header "TTL:86400" --header "Encryption: salt=KYw1fpU-Dg4w1qFcrPY3rQ" --header "Crypto-Key: dh=BOwb4OiwboYRrbhhXh056xFZ8pk8kfQR27Gmu3EdYPG9DkLoKRqA_d4Z_TbT2VYMfHVkGS-dY45rZ8tAimqSWrk" --header "Content-Encoding:aesgcm" https://android.googleapis.com/gcm/send --header "Content-Length: 363" -d "{\"registration_ids\":[\"elmll0-ynBY:APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\"],\"delay_while_idle\":false,\"collapse_key\":\"hipush-notification\",\"time_to_live\":86400,\"raw_data\":\"rXJHqmhxmTde+297wtb3Tpj5Lq5C8cd2eYW5qTBoC3huGVTOPog6+I2Y6wQEYqP1QIAvUA0NFtYC7Zr\/iCR1sGcu\"}"
      

      • Google response is :

       {"multicast_id":7840093467258640262,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1465913901129815%f4d428f3bf364ddd"}]}
      

      I got same response with success. My chrome is in version 51.

      Can someone explain me where is my error ?

      Best regards,

      Mehdi

      解决方案

      Which language are you using? You could use one of the libraries here https://github.com/web-push-libs (Node.js, PHP, Python, Java currently supported), which have already fixed the problem for you.

      这篇关于谷歌gcm raw_data(有效载荷加密),未收到推送事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆