aliyun / alicloud-android-demo

992 stars 552 forks source link

onNotificationReceivedInApp回调不走 #250

Closed WangStormstout closed 1 year ago

WangStormstout commented 1 year ago
  1. 产品: 移动推送
  2. sdk版本:3.8.0

设置前台不build后onNotificationReceivedInApp回调不走 服务端请求传了AndroidNotificationBarType

D/EMASNAccs_DefaultLog: [MPS:AgooMessageReceiver] AgooMessageReceiver onReceive begin...intent=Intent { act=com.alibaba.sdk.android.push.RE
E/EMASNAccs_DefaultLog:     at xxxxx.AliPushMessageReceiver.onNotificationReceivedInApp(Unknown Source:17)
        BasicCustomPushNotification notification = new BasicCustomPushNotification();
        notification.setBuildWhenAppInForeground(false);
        boolean res = CustomNotificationBuilder.getInstance().setCustomNotification(BASIC_CUSTOM_NOTIF_ID, notification);
WangStormstout commented 1 year ago
[AgooPushHandler] Notify message error: java.lang.NullPointerException: Parameter specified as non-null is null: met
    at com.gpower.coloringbynumber.broadcast.AliPushMessageReceiver.onNotificationReceivedInApp(Unknown Source:17)
    at com.alibaba.sdk.android.push.MessageReceiver.onNotificationReceivedWithoutShow(Unknown Source:0)
    at com.aliyun.ams.emas.push.b.a(Taobao:185)
    at com.aliyun.ams.emas.push.b.a(Taobao:105)
    at com.aliyun.ams.emas.push.AgooMessageReceiver.onReceive(Taobao:44)
    at com.alibaba.sdk.android.push.MessageReceiver.onReceive(Unknown Source:0)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4843)
    at android.app.ActivityThread.access$1800(ActivityThread.java:315)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2297)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8751)

2022-11-17 15:36:01.001 19815-19815 E/EMASNAccs_DefaultLog:     at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

从日志上可以看出当选择打开方式是APPLICATION时 是不需要传AndroidActivity 和 AndroidOpenUrl 但是这个onNotificationReceivedInApp会去校验这个两个参数导致空指针

WangStormstout commented 1 year ago

extends的Receiver如果是kotlin的话 将函数

override fun onNotificationReceivedInApp(
        context: Context?,
        title: String,
        summary: String,
        extraMap: Map<String?, String?>,
        openType: Int,
        openActivity: String?,
        openUrl: String?
    )

openActivity 和 openUrl改为可空