Closed est7 closed 6 years ago
你有没有调用 notifyJSDidLoad?
iOS没有这个JPushModule.notifyJSDidLoad,怎么在后台监听点击推送的跳转?
直接监听 openNotification 这个事件。
应用进入后台再唤起,在App.js里面不走任何方法,在哪里监听呢?
handleNotification () { if (Platform.OS === 'ios') { JPushModule.getRegistrationID((registrationId) => { console.log(registrationId) }) JPushModule.addGetRegistrationIdListener((map) => { console.log(map) })
JPushModule.addReceiveNotificationListener(event => {
console.log('alertContent: ' + JSON.stringify(event))
})
JPushModule.addOpenNotificationLaunchAppListener(map => {
console.log('Opening notification!')
console.log('map.uri: ' + map.uri)
if (this.navigationRef.state.nav.index == 0) {
console.log(map.uri)
} else {
this.schemeNavigate(map.uri)
}
})
JPushModule.addReceiveOpenNotificationListener(map => {
console.log('Opening notification!')
console.log('map.extra: ' + map.uri)
})
}
else {
JPushModule.getInfo((map) => {
console.log(map)
})
NativeModules.JPushModule.notifyJSDidLoad((resultCode) => {
if (resultCode === 0) {
JPushModule.getRegistrationID((registrationId) => {
console.log('registrationId: ' + registrationId)
})
}
})
JPushModule.addReceiveOpenNotificationListener(map => {
console.log('Opening notification!')
console.log('map.extra: ' + map.extras)
// JPushModule.jumpToPushActivity("SecondActivity");
let extras = JSON.parse(map.extras)
this.schemeNavigate(extras.uri)
})
}
}
componentDidMount () { this.handleNotification() } 这段代码写在App.js里面,这样监听,可以吗?
什么系统。
iOS 9.3.4
那篇文章我之前就看过了,我问的是既然App.js在iOS上面唤起已经不走任何方法了,例如:componentWillMount ()等,那这个监听方法写在哪里才能在App从后台唤起的时候调用
现在的需求是App点击通知在后台唤起时候我能够拿到监听,但是在App.js什么方法都不会执行,怎么解决呀?不在后台我能够拿到监听JPushModule.addOpenNotificationLaunchAppListener,但是在后台唤起handleNotification ()我都不知道在哪里会可以调用?
iOS 9 只有 receivenotification 方法,没有openNotification 方法
JPushModule监听是在App.js做监听吗?
确保事件触发之前监听就行,没有特别要求, 放到 index.js 都可以
index.js里面我放的App.js,我从后台唤起App时候,没有调用任何App.js的方法
应用唤起时是在 App.js 页面?
是的
你说唤起没回调都不执行,用demo 测试没有问题,可以参考demo
你的运行环境
win+npm5.4+nodev8.9
期望效果
告诉我们你希望达到什么效果。
实际效果
告诉我们实际是什么效果。
重现步骤
Debug logs