Parse.com关闭推送通知的通知 [英] Parse.com disable push notification notification

查看:144
本文介绍了Parse.com关闭推送通知的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要处理的推送通知不显示它在通知栏,什么Parse.com默认完成了。

I want to handle the push notification without showing it in the notification bar, what Parse.com does by default.

Parse.com 要求的清单中的条目,所以我不能将其更改为自己的的BroadcastReceiver ,因为它不会工作。

Parse.com requires the entry in manifest, so I can't change it to my own BroadcastReceiver, because It will not work.

    <receiver android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:priority="1">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="packagename" />
        </intent-filter>
    </receiver>

因此​​,我所做的是创建第二个接收器相同的的IntentFilter ,但具有更高的优先级。

So what I have done is creating the second receiver for the same IntentFilter, but with higher priority.

    <receiver android:name="packagename.ParseComPushReceiver"
        android:permission="com.google.android.c2dm.permission.SEND"
        android:priority="2">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="packagename" />
        </intent-filter>
    </receiver>

和有我试着中止广播

@Override
public void onReceive(final Context context, final Intent intent) {
    abortBroadcast();
    // handle here
}

但不幸的是,这我还看到收到的通知,在通知栏通知。

But unfortunately, it I still see the "Notification received" notification in the notification bar.

推荐答案

您实际上可以使用自己定制的广播接收器与解析。它记录了推送指南中这里

You can actually use your own custom Broadcast Receiver with Parse. It's documented in the Push Guide here.

具体而言,替换:

    <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());
    }
  }
}

这篇关于Parse.com关闭推送通知的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆