在解析控制檯中,它顯示傳遞報告成功,但onPushReceive根本沒有被調用。我在這裏錯過了什麼?任何幫助,將不勝感激。無法在Android中使用Parse接收推送通知
以下是我的代碼。 清單代碼:
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.appname" />
</intent-filter>
</receiver>
<service android:name="com.parse.PushService" />
<receiver android:name="com.appname.PushReceiver"
android:permission="com.google.android.c2dm.permission.SEND"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.OPEN" />
<action android:name="com.parse.push.intent.DELETE" />
</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" />
<!--IMPORTANT: Change "com.parse.starter" to match your app's package name.-->
<category android:name="com.appname" />
</intent-filter>
</receiver>
PushReceiver類:
public class PushReceiver extends ParsePushBroadcastReceiver
{
@Override
protected void onPushReceive(Context context, Intent intent) {
super.onPushReceive(context, intent);
Log.v("Push Receive called...", "");
if (intent == null)
return;
try
{
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
可能是你的google-services.json中的錯誤 – Alexander
解析被關閉。你應該轉移到另一項服務。 –
@DevendraSingh Ya我知道,這只是幾個月的臨時解決方案。 – Anirudh