ParsePushBroadcastReceiver中的组推送通知

时间:2016-02-24 11:49:30

标签: android push-notification

我试图将Whatsapp中的几个通知放在一起,使用自定义ParsePushBroadcastReceiver。

public class ParseAppReceiver  extends ParsePushBroadcastReceiver {

private String mStringMessage;

@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
}

@Override
protected void onPushReceive(Context context, Intent intent) {
    super.onPushReceive(context, intent);

    JSONObject data = getDataFromIntent(intent);

    try {
        mStringMessage = data.getString("alert");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    Notification notif = new NotificationCompat.Builder(context)
            .setContentTitle("Example")
            .setContentText(mStringMessage)
            .setSmallIcon(R.drawable.ic_launcher)
            .setGroup(GROUP_PUSH_KEY)
            .build();

    NotificationManagerCompat notificationManager =
            NotificationManagerCompat.from(context);

    notificationManager.notify(0, notif);

}

private JSONObject getDataFromIntent(Intent intent) {
  ...
}

我为通知分配了一个组,但如果不是第二个推送通知覆盖,则不会对其进行分组。

如果有任何想法,请帮助我,提前致谢。

0 个答案:

没有答案