点击通知收不到ACTION_NOTIFICATION_OPENED广播

dxplay
2017-05-23 04:31 2k 0

jcenter集成,

public class JPushReceiver extends BroadcastReceiver  {

    public static String RegistrationID;
    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle bundle = intent.getExtras();
        if (LogUtil.DEBUG) {
            LogUtil.e(this, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
        }
        if (bundle == null) {
            return;
        }
        RegistrationID = JPushInterface.getRegistrationID(context);

        if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
            String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
            sendRegistrationID(regId, context);
        } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {

        } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
            int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);

        } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
            if (bundle != null) {
                try {
                    PushEntity en = new PushEntity();
                    en.title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
                    en.description = bundle.getString(JPushInterface.EXTRA_ALERT);
                    String extra = bundle.getString(JPushInterface.EXTRA_EXTRA);
                    if (!TextUtils.isEmpty(extra)) {
                        JSONObject json = new JSONObject(extra);
                        en.type = Integer.parseInt(json.getString("type"));
                        en.id = json.getString("id");
                        switch (en.type) {
                            case 1:
                                if (json.has("special_id")) {
                                    en.param1 = json.getString("special_id");
                                }
                                if (json.has("special_type")) {
                                    en.param2 = json.getString("special_type");
                                }
                                break;
                            case 3:
                                if (json.has("url")) {
                                    en.param1 = json.getString("url");
                                }
                                break;
                            case 6:
                            case 8:
                            case 9:
                                break;
                            case 10:
                                en.param1 = extra;
                                break;
                        }
                        Bundle b = new Bundle();
                        b.putSerializable(_BaseActivity._EXTRA_Serializable, en);
                        Intent in = new Intent(context.getApplicationContext(), MainActivity.class);
                        in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        in.putExtras(b);
                        context.getApplicationContext().startActivity(in);
                    }
                } catch (Exception e) {
                    if (LogUtil.DEBUG) {
                        LogUtil.e(e);
                    }
                }
            }
        } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {

        } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {

        } else {

        }
    }

打印log

发现通知消息接收到了,也显示在通知栏了,但是点击通知栏没有收到ACTION_NOTIFICATION_OPENED事件

1个回答

热门排序
  • 代码方面只能你自己debug啦 点击跳转示例:https://docs.jiguang.cn/jpush/client/Android/android_senior/#vs 如果App有杀死过https://community.jiguan 展示全部