Issue
I have been trying to see why I haven't been receiving any push notifications and I have narrowed it down to this. My broadcast intent isn't being passed any information due to it being cancelled. This causes my device to be unregistered. I have looked through various questions here and none have seemed to work. I'm hoping someone here can help me.
This is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.amosang.pushtest" >
<!-- GCM Permissions - Start here -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.example.amosang.pushtest.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.amosang.pushtest.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity"
android:label="@string/title_activity_home" >
</activity>
</application>
<receiver
android:name=".GCMBroadcastReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTER" />
<action android:name="com.example.amosang.pushtest" />
</intent-filter>
</receiver>
<service android:name=".GCMNotificationIntentService" />
I suspect it has something to do with my manifest but I've looked through it so many times that I can't really see much difference.
These are the errors
broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.example.amosang.pushtest (has extras) }
Unregister application com.example.amosang.pushtest for user 0
Solution
Not entirely sure if this is the one causing your issue, but I think it's because your <receiver>
and <service>
tags are outside the <application>
tag. I've checked a similar post, the Google Android GCM AndroidManifest Sample, and the sample code provided in GCM Android Quickstart and all of them have the <receiver>
and <service>
tags inside the <application>
tag. Care to try it out.
Answered By - AL.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.