jpush-react-native icon indicating copy to clipboard operation
jpush-react-native copied to clipboard

iOS设备在接收到一条推送通知时多次运行NativeAppEventEmitter.addListener('ReceiveNotification', )

Open zerotalk opened this issue 10 years ago • 4 comments

iOS设备在接收到一条推送通知时多次重复运行NativeAppEventEmitter.addListener('ReceiveNotification', (notification)=>{console.log("推送通知");console.log(notification);})(Android端那三个函数没问题) 而我希望的是接收到一条推送消息就运行一次NativeAppEventEmitter.addListener('ReceiveNotification', (notification)=>{console.log("推送通知");console.log(notification);})

这算BUG吗

zerotalk avatar Jul 13 '16 07:07 zerotalk

有在componentWillUnmount函数中调用 remove方法吗?

huangminlinux avatar Jul 14 '16 14:07 huangminlinux

@huangminlinux 这个问题可能是在调试的时候出现异常退出,没调用到componentWillUnmount下一次启动就会增加一次调用ReceiveNotification方法,这里有没有什么办法可以在异常退出前调用remove结束它的周期,使其不会对下一次调用NativeAppEventEmitter.addListener('ReceiveNotification', ***)造成影响

zerotalk avatar Jul 15 '16 01:07 zerotalk

讲道理第二次启动不会受第一次设置的影响

huangminlinux avatar Jul 22 '16 05:07 huangminlinux

谢谢,异常我再这里再处理一下吧

zerotalk avatar Jul 25 '16 06:07 zerotalk