简体   繁体   English

未收到Amazon SNS的GCM推送通知

[英]Not receiving GCM push notification from Amazon SNS

I am trying to send Push notification to android app through php . 我试图通过PHP发送推送通知Android应用程序。 I setup amazon sns account and created SNS Platform using Google Server key for GCM API . 我设置了amazon sns帐户,并使用Google Server密钥为GCM API创建了SNS平台

Using AWS credentials , i wrote a cron which reads notification message from database and publishes to sns service using amazon php api. 使用AWS凭证 ,我写了一个cron ,它从数据库中读取通知消息,并使用amazon php api发布到sns服务。 I am getting Amazon endpoint in cron on which i publish notification. 我在cron上获得了亚马逊端点,我发布了通知。

I am receiving status as pass and a requestid for notification. 我收到通过状态和通知请求 But actual notification is not receiving on device. 但实际通知未在设备上接收。

Array ( [data] => Guzzle\Service\Resource\Model Object ( [structure:protected] => [data:protected] => Array ( [MessageId] => ac9e1d0c-43a4-5d1a-833d-50c94465421d [ResponseMetadata] => Array ( [RequestId] => c1da8997-2e32-50d0-a092-c45229f36fd7 ) ) ) )

Steps I followed: 我遵循的步骤:

  1. Created google API credentials for GCM. 为GCM创建了Google API凭据。 Used projectid in app and Server key for Amazon platform 在应用程序中使用projectid,在Amazon平台上使用Server密钥

  2. Created user in aws and added policies with all access for sns 在aws中创建用户并添加了具有sns所有访问权限的策略

  3. Used amazon user credentials in php aws api 在php aws api中使用amazon用户凭据

  4. Created amazon sns application platform form Android/GCM and used google server key there. 从Android / GCM创建了亚马逊sns应用平台,并在那里使用了谷歌服务器密钥。

  5. Added Application ARN received from above steps to php api calls. 从上述步骤中添加了应用ARN到php api调用。

  6. In php cron, created AmazonEndpoint for device using registration_id received from GCM. 在php cron中,使用从GCM收到的registration_id为设备创建了AmazonEndpoint。

  7. Published notification message on amazon endpoint. 在亚马逊端点上发布通知消息。

  8. and stuck ......not receiving notification on device even after getting success status in api call 并且卡住......即使在api通话中获得成功状态之后也没有在设备上接收通知

Can anyone tell me exact steps? 谁能告诉我确切的步骤? Am i missing anything? 我错过了什么吗?

I used Firabase and AWS SNS service for sending from php. 我使用Firabase和AWS SNS服务从php发送。 I did it step by step according to this video tutorial https://youtu.be/iBTFLu30dSg (on russian but with English subtitles). 我按照这个视频教程https://youtu.be/iBTFLu30dSg (俄语但有英文字幕)一步一步地做了。 It works well for me now and I successfully receive push notification from my php code on the mobile devices 它现在适用于我,我成功地从移动设备上的PHP代码接收推送通知

use a json to topic like: 使用json主题如:

{
  "default": "Msg test from sns",
  "GCM": "{\"data\":{\"id\":\"161223182046\",\"badge\":1,\"message\":\"Msg test from sns\",\"title\":\"test\",\"_event\":{\"created\":1482547772}}}"
}

For an endpoint quit default row: 对于端点退出默认行:

{
  "GCM":"{\"data\":{\"id\":\"161223182046\",\"badge\":1,\"message\":\"Msg test from sns\",\"title\":\"test\",\"_event\":{\"created\":1482547772}}}"
}

Where id and _event.created rows are unique for each push. 其中id_event.created行对于每次推送都是唯一的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM