没有收到任何Parse Push

时间:2015-05-28 13:47:47

标签: android parse-platform broadcastreceiver

我已经按照Parse.com上列出的每个步骤进行了操作。我第一次尝试使用自定义BroadcastReceiver(子类化ParsePushBroadcastReceiver),但即使没有这样,Parse Push似乎也不起作用。以下是我的AndroidManifest.xml(关闭<application>代码之前的代码段):

<!-- 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>

...就在我打开<application>标签之前:

<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" />

我尝试过各种各样的组合,但绝对没有推动似乎正在进行。

所有帮助非常感谢! : - )

1 个答案:

答案 0 :(得分:0)

好吧,我会被诅咒!以下是我如何使用它。首先,我转而使用Parse Push QuickStart guide for Android中的代码而不是Parse过时的教程。在4个浪费时间结束时,我现在看到教程中遗漏了一个重要的WAKE_LOCK权限(Ikr?)。 (据推测)更重要的是,在你的应用程序类中,这里的变化似乎可以解决它 - 大脑刺客:

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
}