I've followed every step outlined on Parse.com. I was first attempting to use a custom BroadcastReceiver
(subclassing ParsePushBroadcastReceiver
), but even without so, Parse Push doesn't seem to work. Here is a look at my AndroidManifest.xml
(snippet just before closing <application>
tag):
<!-- For Parse Push -->
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
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.REGISTRATION" />
<category android:name="my.package.name" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
...and right before I open the <application>
tag:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="my.package.name.permission.C2D_MESSAGE" />
<uses-permission android:name="my.package.name.permission.C2D_MESSAGE" />
I have tried pushing in all sorts of combinations, but absolutely no push seems to be going through.
All help greatly appreciated! :-)
Well I'll be arsed! Here's how I got it to work. First off, I switched to using the code in the Parse Push QuickStart guide for Android
instead of an outdated tutorial by Parse. At the end of 4 wasted hours, I now see that an essential WAKE_LOCK
permission is left out of the tutorial (Ikr?). (Presumably) More importantly, here's the change that seems to fix it, cerebral assassin as it may be - in your Application class:
public void onCreate() {
Parse.enableLocalDatastore(getApplicationContext());
Parse.initialize(this, "fo00", "b4r");
ParseFacebookUtils.initialize(this);
ParseInstallation.getCurrentInstallation().saveInBackground();
super.onCreate(); // Moved this from right at the top, to right at the bottom
}