React-Native 消息推送

在这里我们可以选择大厂的推送,优先使用极光推送,下一篇将介绍如何使用阿里推送。

使用说明

PS: 真没想到极光大厂出的官方文档也有问题,这里列出是最新版本修复可用版

创建新项目

react-native init rn_jpush

过程(省略)

This will walk you through creating a new React Native project in /Users/huanghuanlai/dounine/github/rn_push
Using yarn v1.9.4
Installing react-native...
yarn add v1.9.4
info No lockfile found.
[1/4] ?  Resolving packages...
[2/4] ?  Fetching packages...
[3/4] ?  Linking dependencies...

安装jpush

cd rn_jpush
npm install jpush-react-native jcore-react-native --save

自动配置

react-native link
rnpm-install info Linking jcore-react-native ios dependency 
rnpm-install info Platform 'ios' module jcore-react-native has been successfully linked 
? Input the appKey for JPush 自己的AppKey
patching android/settings.gradle...
patching android/**/AndroidManifest.xml...
patching android/**/build.gradle...
patching ios/**/AppDelegate.m...
done!
rnpm-install info Linking jpush-react-native ios dependency 
rnpm-install info Platform 'ios' module jpush-react-native has been successfully linked 
rnpm-install info Platform 'android' module jpush-react-native is already linked

修改AppDelegate.m中的下面代码

[JPUSHService setupWithOption:launchOptions appKey:@"xxxxxxxxxxxxxxxxx"
                        channel:nil apsForProduction:nil];
# 修改为
JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
  entity.types = UNAuthorizationOptionAlert|UNAuthorizationOptionBadge|UNAuthorizationOptionSound;
  [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
  [JPUSHService setupWithOption:launchOptions appKey:@"xxxxxxxx"
                        channel:nil apsForProduction:false];

通知勾选

image.png
image.png

消息发送

image.png
image.png

项目

https://github.com/dounine/rn_jpush

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值