点击通知收不到ACTION_NOTIFICATION_OPENED广播


(haha) #1

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事件


#2

代码方面只能你自己debug啦

点击跳转示例:
https://docs.jiguang.cn/jpush/client/Android/android_senior/#vs

如果App有杀死过


(haha) #3

我测试是app在前台收到通知,点击通知栏收不到ACTION_NOTIFICATION_OPENED的广播,并不是app退出或者被杀死的状态下


(haha) #4

麻烦看下 我的log 已经很明显 我的自定义receiver是起作用了的,推送的通知收到了的,但是打开的事件却没有收到,我表示很无奈唉


(haha) #5

问题解决了 更新下了版本 就ok了

那么问题来了 求我此时的阴影面积???


#6

好的,解决了就行,因我这边没收到bug与修复报告所以不太清楚是否与SDK版本有关。感谢分享你的解决方案