我无法弄清楚如何使这个方法适用于从Web控制台发送而不是从设备构建的推送,因此默认的“Notification Received”消息仍然保持通过。
对我来说有用的是将android:exported =“false”添加到parse.com条目中,如下所示:
<receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" android:exported="false"> <intent-filter> <action android:name="com.example.DISABLE_PARSE_PUSH" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.example" /> </intent-filter> </receiver> <service android:name="com.parse.PushService" />
这会禁用默认通知。
您实际上可以使用自己的自定义广播接收器与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.example.MyCustomReceiver" android:exported="false"> <intent-filter> <action android:name="com.example.UPDATE_STATUS" /> <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>
并实现自己的接收器:
public class MyCustomReceiver extends ParsePushBroadcastReceiver { private static final String TAG = "MyCustomReceiver"; @Override public void onReceive(Context context, Intent intent) { try { String action = intent.getAction(); String channel = intent.getExtras().getString("com.parse.Channel"); JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data")); // Custom behavior goes here } catch (JSONException e) { Log.d(TAG, "JSONException: " + e.getMessage()); } } }