安卓获取和点击推送通知打开应用
if (Platform.OS === 'android') {
JPushModule.addReceiveNotificationListener((message) => {
console.log("ANreceive notification: ", message);
});
JPushModule.addReceiveOpenNotificationListener((map) => {
console.log("ANOpening notification!");
});
}
IOS获取和点击推送通知打开应用
//-----------jpush ios start
if (Platform.OS === 'ios') {
this.subscription = NativeAppEventEmitter.addListener(
'OpenNotification',
(notification) => {
console.log('打开推送',notification);
}
)
this.subscription = NativeAppEventEmitter.addListener(
'ReceiveNotification',
(notification) => {
console.log('-------------------收到推送----------------');
console.log(notification);
}
);
}
//-----------jpush ios end
删除提示消息
提醒各位小伙伴:设置成功后会有toast提示,建议把 项目/node_modules/jpush-react-native/android/src/main/java/cn/jpush/reactnativejpush/JPushModule.java,这个文件中的 Logger.toast()全部注释或者删除掉,有的是一行,有的是两行,请注意
网友评论