我正在将Parse SDK更新为1.7版,并在使用方法ParsePush.subscribeInBackground()
时发生以下崩溃:
10-02 12:56:06.426: E/AndroidRuntime(5441): java.lang.IllegalStateException: In order to use the ParsePush.subscribe or ParsePush.unsubscribe methods you must add the following to your AndroidManifest.xml:
10-02 12:56:06.426: E/AndroidRuntime(5441): <receiver android:name="com.parse.ParsePushBroadcastReceiver"
10-02 12:56:06.426: E/AndroidRuntime(5441): android:exported="false">
10-02 12:56:06.426: E/AndroidRuntime(5441): <intent-filter>
10-02 12:56:06.426: E/AndroidRuntime(5441): <action android:name="com.parse.push.intent.RECEIVE" />
10-02 12:56:06.426: E/AndroidRuntime(5441): <action android:name="com.parse.push.intent.OPEN" />
10-02 12:56:06.426: E/AndroidRuntime(5441): <action android:name="com.parse.push.intent.DELETE" />
10-02 12:56:06.426: E/AndroidRuntime(5441): </intent-filter>
10-02 12:56:06.426: E/AndroidRuntime(5441): </receiver>
10-02 12:56:06.426: E/AndroidRuntime(5441): (Replace "com.parse.ParsePushBroadcastReceiver" with your own implementation if you choose to extend ParsePushBroadcastReceiver)
10-02 12:56:06.426: E/AndroidRuntime(5441): at com.parse.ParsePush.checkForManifestAndThrowExceptionIfNeeded(ParsePush.java:135)
10-02 12:56:06.426: E/AndroidRuntime(5441): at com.parse.ParsePush.subscribeAsync(ParsePush.java:65)
10-02 12:56:06.426: E/AndroidRuntime(5441): at com.parse.ParsePush.subscribeInBackground(ParsePush.java:79)
10-02 12:56:06.426: E/AndroidRuntime(5441): at com.parse.ParsePush.subscribeInBackground(ParsePush.java:88)
尽管事实上我已经从Parse guide复制了上面的代码并且已经在ma个AndroidManifest.xml中提到了所有行。
答案 0 :(得分:7)
我刚刚注意到Parse指南页面上崩溃和片段的文本不同 - 它应该是
<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.ParsePushBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="com.push.intent.RECEIVE" />
<action android:name="com.push.intent.DELETE" />
<action android:name="com.push.intent.OPEN" />
</intent-filter>
</receiver>
(注意动作名称中缺少.parse
。)