AWS SNS-推送的GCM显示为从Cloudwatch发送但未在移动设备中收到 [英] AWS SNS - Push for GCM showing as sent from Cloudwatch but not received in Mobile Device

查看:176
本文介绍了AWS SNS-推送的GCM显示为从Cloudwatch发送但未在移动设备中收到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从自定义推送通知迁移到AWS SNS.我做了以下事情.

I am migrating from custom Push Notification to AWS SNS. I did the following.

  • 配置的AWS SNS主题
  • 创建的平台应用程序
  • 创建的端点
  • 平台应用程序的预定端点

我正在尝试使用用于Ruby的发布" API推送通知的最后一步.我收到message_id作为响应.它还记录为成功/已在CloudWatch中交付.但是设备中未收到推送"信息.

I am trying the last step for Pushing the Notification using 'publish' API for Ruby. I receive the message_id as response. It also logs as success / delivered in CloudWatch. But the Push is not received in the device.

设备有效 设备具有有效的推送令牌 该设备已安装了应用程序.

The device is valid The device has a valid push token the device has the application installed.

我尝试过的区域的消息格式如下

The message format I tried areas follows

{"GCM"=>{"data"=>"{\"message\":\"message\",\"url\":\"url\"}"}, :default=>"default"}

SNS发布API语法

SNS publish API syntax

client.publish({target_arn: endpoint_arn, message: message.to_json, subject: "SNS test", message_structure: :json})

仅供参考,在将此标记为其他任何问题之前,请注意,我已经参考了之前的所有答案,没有任何帮助.因此,我正在提出一个新的.

FYI, Before marking this as duplicate of any other question, please note that i have referred all previous answers and nothing helped me. hence I am raising a new one.

推荐答案

我的消息形成有问题.我通过使用android进行调试解决了.推送到达了设备,但不是预期的格式.因此,该推送未在设备中显示.我正在发送

There is a problem with my message formation. I figured it out by debugging with android . The Push reached the device but it was not in the expected format. So the push was not shown in the device. I was sending

{"GCM"=>{"data"=>"{\"message\":\"message\",\"url\":\"url\"}"}, :default=>"default"}

但是Android系统在我的消息中期望有徽章"和其他一些键.我尝试过

But the Android system was expecting 'badge' and some other keys in my message. I tried with

 {:default=>"default", :GCM=>"{\"data\":{\"message\":\"test\",\"url\":\"https://s3.amazonaws.com/mcds_fulltext/aapg/gsaapgbull/issues/74/android_hdpi/cover_74.gif\",\"registration_ids\":\"arn:aws:sns:us-****-1:*********7:endpoint/GCM/gs*****_gcm/*********************\",\"badge\":\"10\",\"vol\":\"128\",\"issue\":\"10\",\"journal_name\":\"gsaapg\",\"abbr\":\"aapg\"},\"collapse_key\":\"New Article badge\"}"}

现在它可以正常工作了.

Now it works as expected.

这个特定的JSON可能并不适合所有人.但是,此问题的原因是消息JSON不是移动应用程序的预期格式.这对于遇到类似问题的人可能会有所帮助.

This particular JSON might not be appropriate for everyone. But the cause of this issue is the message JSON is not in the expected format for the mobile app. This might be helpful for someone who face the similar issue.

这篇关于AWS SNS-推送的GCM显示为从Cloudwatch发送但未在移动设备中收到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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