【问题标题】:GCM not delivering Amazon SNSGCM 未提供 Amazon SNS
【发布时间】:2015-05-14 00:26:16
【问题描述】:

我已经使用 GCM 和 SNS 设置了一个 AWS 服务器和一个带有推送通知的 Android 应用程序。

应用注册成功,即BroadcastReceiver收到带有注册ID的通知。问题是没有 SNS 通知通过。

有没有办法检查设备是否收到了通知,但由于某种原因没有发送到BroadcastReceiver

另外,也许我做错了什么(可能是包名)?这是清单:

...
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package.tester"
... >
<permission
    android:name="my.package.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="my.package.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
...
<application
    ... >
    <service android:name="my.package.path.to.PushNotificationsService" >
    </service>
...
    <receiver android:name="my.package.path.to.PushNotificationsBroadcastReceiver" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <action android:name="com.google.android.c2dm.intent.REGISTER" />

            <category android:name="my.package" />
        </intent-filter>
    </receiver>
...
</application>
</manifest>

【问题讨论】:

    标签: android amazon-web-services google-cloud-messaging amazon-sns


    【解决方案1】:

    您可以检查几件事:

    • 接收方需要com.google.android.c2dm.permission.SEND 权限。请在接收者块中添加android:permission="com.google.android.c2dm.permission.SEND"
    • 意图过滤器的类别应与您的应用程序名称匹配
    • 如果您的设备连接到 WIFI,请确保将 GCM 端口(5228、5229 和 5230)列入白名单。

    进一步阅读:

    【讨论】:

      【解决方案2】:

      谢谢,但最后我发现问题根本不在客户端。问题是我将JSONObject.toString() 放在数据值中,而不仅仅是JSONObject

      显然 GCM 无法处理,但也不会抛出任何错误...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-22
        • 2015-07-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多