I've set up a AWS server and an Android app with push notifications using GCM and SNS.
The app registers successfully, ie the BroadcastReceiver
gets a notification with the registration ID. Problem is no SNS notifications go through.
Is there a way to check if the notification was received by the device, but not delivered to the BroadcastReceiver
for some reason?
Also, maybe I've done something wrong (possibly with the package name)? Here is the manifest:
...
<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>
A few things you can check:
com.google.android.c2dm.permission.SEND
permission. Please add android:permission="com.google.android.c2dm.permission.SEND"
in the receiver block Further reading:
Thanks, but finally I've found that the problem was not in the client side after all. The problem was I put JSONObject.toString()
in the data value instead of just JSONObject
.
Apparently GCM can't handle that, but doesn't throw out any error either...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.