I know that this question has been asked a lot, but many also went unanswered.
However, I use Parse.com to send push-notifications to devices. On iOS it works fine. But it's not receives on Android devices.
When I looking at Push tab on service page I see that no one push wasn't sent. Value in 'Pushes Sent' column is 0 (zero).
Then I sent push through GCM (gcm-http.googleapis.com) and my device received the message.
Perhaps the problem may be in settings of Parse.com?
I was added Sender ID (Project number) & API Key from Google.
My AndroidManifest.xml immediately before the opening </application>
tag:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission android:name="my.app.name.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="my.app.name.permission.C2D_MESSAGE" />
My AndroidManifest.xml immediately before the closing </application>
tag:
<meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/ic_stat_bt"/>
<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.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>
<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.app.name" />
</intent-filter>
</receiver>
My ApplicationClass
package my.app.name;
import android.util.Log;
import android.os.Bundle;
import com.parse.Parse;
import com.parse.ParseInstallation;
import com.parse.ParsePush;
import com.parse.SaveCallback;
import com.parse.ParseException;
public class MyApplication extends android.app.Application {
@Override
public void onCreate() {
super.onCreate();
// Parse
Parse.initialize(this, "", "");
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully installed.");
ParsePush.subscribeInBackground("", new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
} else {
Log.e("com.parse.push", "failed to subscribe for push", e);
}
}
});
} else {
Log.e("com.parse.push", "failed to install", e);
}
}
});
}
...
On the advice of Clayton Oliveira I noticed, when I install my app and initialize it first time I get my token and pushes works fine. But when I open my app again I get another token and pushes are not working until I delete all data from Parse, uninstall my app & install it again.
Any ideas?
I was facing the same problem just now ! Here's what did the trick:
I uninstalled my app and deleted all the data previously stored on Parse (Installation, Session and User).
After that, just install your app again and if you did everything right from the Parse tutorial: https://www.parse.com/tutorials/android-push-notifications
Try send another Test Push ;)