addReceiveOpenNotificationListener有的时候会执行有的时候不会执行

标签: #<Tag:0x00007f6580c42718>

点击推送的消息,有的时候会执行addReceiveOpenNotificationListener,有的时候不执行,问题出在哪里呢

下面是我写的代码:

componentDidMount() {
    // 新版本必需写回调函数
    JPushModule.notifyJSDidLoad((resultCode) => {
    });
    // 接收自定义消息
    JPushModule.addReceiveCustomMsgListener((message) => {
    });
    // 接收推送消息
    JPushModule.addReceiveNotificationListener((message) => {
    })
    // 传tag,判断是哪类客户
    storage._load('UserInfo', function(successData){
      this.setState({userId: successData.id});
      const id = String(successData.id);
      this.getNoticeInfomation(id);
      JPushModule.setTags([id], (success) => {
      },()=>{
      })
    }.bind(this), function(failData){
    });
    // JPush.jPushEventListener(this);
    // 用户点击通知,打开通知
    JPushModule.addReceiveOpenNotificationListener((map) => {
      this.props.navigator.push({
        screen:'Notification',
        navigatorStyle:{
          navBarHidden:true,
        },
        passProps: {
          id: this.state.userId,
        }
      })
    })
    JPushModule.addGetRegistrationIdListener((registrationId) => {
		});
  }

你使用的是插件吗,什么插件,版本是多少,问题出现在 Android?

当点击不执行的时候,日志里面打印了什么,处于一个什么场景,譬如都是在后台或者杀死的状态等

“jcore-react-native”: “^1.3.2”,
“jpush-react-native”: “^2.5.3”,
“react-native”: “0.55.4”,
暂时我这里没打印日志,我不知道怎么能打印日志
现在的情况就是,消息栏会有消息,但是我调用addReceiveOpenNotificationListener这个方法跳转别的页面,有的时候会成功,有的时候无效

现在我需要先打印日志吗

react 给了一个专门的方案,看下readme

嗯嗯,我是按照这个配置的

这个是我刚点击消息,然后出现的日志,不知道出现了啥问题
07-18 11:15:35.288 17953-17997/com.lidar I/System: core_booster, getBoosterConfig = false
07-18 11:15:35.349 383-383/? I/gralloc: Free handle(0x7f83b48a00)
07-18 11:15:35.365 1776-8438/? I/KeyguardService: KGSvcCall verifyUnlock
07-18 11:15:35.365 1776-8438/? W/KeyguardViewMediator: verifyUnlock called when not externally disabled
07-18 11:15:35.383 17953-18256/com.lidar I/System: core_booster, getBoosterConfig = false
07-18 11:15:35.390 17953-17980/com.lidar I/SendBroadcastPermission: action:cn.jpush.android.intent.NOTIFICATION_OPENED, mPermissionType:0
07-18 11:15:35.419 1754-1754/? W/View: requestLayout() improperly called by com.android.systemui.statusbar.phone.IconMerger{6432c22 V.E… …ID 0,0-144,96 #7f1000d7 app:id/notificationIcons} during layout: running second layout pass
07-18 11:15:35.422 17953-17953/com.lidar I/JPushModule: Sending event : openNotification
07-18 11:15:35.424 1022-1707/? E/SensorHub: batch called handle:0 sample_ns:200000000 latency_ns:0
07-18 11:15:35.427 1754-1754/? W/View: requestLayout() improperly called by com.android.systemui.statusbar.phone.IconMerger{6432c22 V.E… …ID 0,0-216,96 #7f1000d7 app:id/notificationIcons} during second layout pass: posting in next frame
07-18 11:15:35.454 1022-1708/? E/SensorHub: batch called handle:0 sample_ns:66667000 latency_ns:0
07-18 11:15:35.458 17953-18422/com.lidar I/System: core_booster, getBoosterConfig = false
07-18 11:15:35.469 1022-1022/? I/TrafficMonitor: update:rxPkts:27,txPkts:28,rxBytes:11991,txBytes:5028
07-18 11:15:35.469 1022-1022/? I/TrafficMonitor: start expired. level:-1
07-18 11:15:35.469 1022-1022/? I/TrafficMonitor: gettimer:interval=2000
07-18 11:15:35.489 1754-1754/? I/SendBroadcastPermission: action:com.android.systemui.statusbar.visible.change, mPermissionType:0
07-18 11:15:35.490 1754-1754/? I/SendBroadcastPermission: action:com.android.systemui.statusbar.visible.change, mPermissionType:0
07-18 11:15:35.494 17149-18424/? E/HwIntelligent3_ActionBarPullDownAction: doAction not pull down return
07-18 11:15:35.497 17149-18424/? E/HwIntelligent3_ActionBarPullDownAction: doAction not pull down return
07-18 11:15:35.575 383-1519/? I/gralloc: Free handle(0x7f78fe9c00)
07-18 11:15:35.576 383-1520/? I/gralloc: Alloc req: dev=0x7f83b02540, w=1440, h=96, format=0x1, usage=0xb00
07-18 11:15:35.577 383-1520/? I/gralloc: Alloc handle(0x7f7dffba00): interfmt=0x1, stride=1472, size=565248
07-18 11:15:35.588 383-383/? I/gralloc: Free handle(0x7f78fe9d00)
07-18 11:15:35.589 383-403/? I/gralloc: Alloc req: dev=0x7f83b02540, w=1440, h=96, format=0x1, usage=0xb00
07-18 11:15:35.589 383-403/? I/gralloc: Alloc handle(0x7f78c16e00): interfmt=0x1, stride=1472, size=565248
07-18 11:15:35.727 17953-18425/com.lidar I/System: core_booster, getBoosterConfig = false
07-18 11:15:35.808 17953-18256/com.lidar I/System: core_booster, getBoosterConfig = false
07-18 11:15:36.212 1022-1708/? I/SendBroadcastPermission: action:android.intent.action.SIG_STR, mPermissionType:0
07-18 11:15:36.212 5098-5110/? W/MessageQueue: Handler (android.telephony.PhoneStateListener$1) {5fc59dd} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.telephony.PhoneStateListener$1) {5fc59dd} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:564)
at android.os.Handler.enqueueMessage(Handler.java:635)
at android.os.Handler.sendMessageAtTime(Handler.java:604)
at android.os.Handler.sendMessageDelayed(Handler.java:574)
at android.os.Handler.sendMessage(Handler.java:511)
at android.os.Message.sendToTarget(Message.java:416)
at android.telephony.PhoneStateListener$2.onSignalStrengthsChanged(PhoneStateListener.java:573)
at com.android.internal.telephony.IPhoneStateListener$Stub.onTransact(IPhoneStateListener.java:133)
at android.os.Binder.execTransact(Binder.java:453)

下面这四句好像是报错了
07-18 11:15:35.424 1022-1707/? E/SensorHub: batch called handle:0 sample_ns:200000000 latency_ns:0
07-18 11:15:35.454 1022-1708/? E/SensorHub: batch called handle:0 sample_ns:66667000 latency_ns:0
07-18 11:15:35.494 17149-18424/? E/HwIntelligent3_ActionBarPullDownAction: doAction not pull down return
07-18 11:15:35.497 17149-18424/? E/HwIntelligent3_ActionBarPullDownAction: doAction not pull down return


image

你无效的时候是不是跳转到的原生页面,用这个API来跳转看一下

好像还是那样的
constructor(props) {
super(props);
this.navigation = props.navigation;
this.state = {
userId: ‘’,
};
this.jumpSecondActivity = this.jumpSecondActivity.bind(this);
}
componentDidMount() {
// 新版本必需写回调函数
JPushModule.notifyJSDidLoad((resultCode) => {
});
// 接收自定义消息
JPushModule.addReceiveCustomMsgListener((message) => {
});
// 接收推送消息
JPushModule.addReceiveNotificationListener((message) => {
})
// 传tag,判断是哪类客户
storage._load(‘UserInfo’, function(successData){
const id = String(successData.id);
JPushModule.setTags([id], (success) => {
},()=>{
})
}.bind(this), function(failData){
});
// JPush.jPushEventListener(this);
this.openNotificationListener = map => {
this.jumpSecondActivity()
}
JPushModule.addReceiveOpenNotificationListener(this.openNotificationListener);
JPushModule.addGetRegistrationIdListener((registrationId) => {
});
}
jumpSecondActivity() {
this.props.navigator.push({
screen:‘Notification’,
navigatorStyle:{
navBarHidden:true,
},
passProps: {
id: this.state.userId,
}
})
}
componentWillUnmount() {
JPushModule.removeReceiveCustomMsgListener();
JPushModule.removeReceiveNotificationListener();
}