【发布时间】:2020-10-05 13:12:33
【问题描述】:
在我的应用关闭时尝试从 HMS Push Kit 接收数据消息。
当应用处于前台时,我能够接收数据消息:
// Registering
componentDidMount(){
this.listener = HmsPushEvent.onRemoteMessageReceived(event => {
const RNRemoteMessageObj = new RNRemoteMessage(event.msg);
const msg = RNRemoteMessageObj.parseMsgAllAttribute(event.msg);
console.log("Data message received : "+msg);
}
}
// Unregistering
componentWillUnmount(){
this.listener.remove();
}
通过使用这种方法,我将无法在应用关闭时收到数据消息,因为侦听器已删除。
有什么想法吗?
【问题讨论】: