RN 集成极光推送 jpush-react-native

jpush-react-native —-是极光推送官方开发的 React Native 版本插件,可以快速集成推送功能。

import JPushModule from 'jpush-react-native';
if (Platform.OS === 'android') {
// 通知 JPushModule 初始化完成,发送缓存事件。
     JPushModule.notifyJSDidLoad((resultCode) => {

     });
}
// 接收自定义消息事件
JPushModule.addReceiveCustomMsgListener((message) => {
    console.log("用户点击打开了,removeReceiveCustomMsgListener");
});
// 接收推送事件
JPushModule.addReceiveNotificationListener((message) => {
    console.log("next removeReceiveNotificationListener: " + message);
    DeviceEventEmitter.emit('hasNewNotice', '通知来了');
});

// 点击推送事件,打开通知
JPushModule.addReceiveOpenNotificationListener((map) => {
   console.log("next removeReceiveOpenNotificationListener ,map.extra: " + map.extras);
   // 可执行跳转操作,也可跳转原生页面
   // this.props.navigation.navigate("SecondActivity");
});

//移除监听消息通知
removeReceivedJPush() {
   JPushModule.removeReceiveCustomMsgListener();
   JPushModule.removeReceiveNotificationListener();
   JPushModule.removeReceiveOpenNotificationListener();
   // 清除所有通知
   JPushModule.clearAllNotifications()
}

参考地址:https://github.com/jpush/jpush-react-native#api

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值