react-native整合极光推送

title date tags
react-native 0.42 整合极光推送
2019-08-29 07:44:20 -0700
react-native

极光推送官网注册应用

配置jpush-react-native

github地址:https://github.com/jpush/jpush-react-native 同样的,打开终端在项目根目录下输入:

npm install [email protected] --save
npm install [email protected] --save

下载完成后,按1、2、3的顺序修改如下文件:

在1中修改如下:

include ':jpush-react-native'
project(':jpush-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jpush-react-native/android')
include ':jcore-react-native'
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')

在2中修改如下:

android {
    defaultConfig {
        applicationId "yourApplicationId" //就是在极光注册的包名
        ...
        manifestPlaceholders = [
                JPUSH_APPKEY: "yourAppKey", //在此替换你的APPKey
                APP_CHANNEL: "developer-default"    //应用渠道号
        ]
    }
}
...
dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile project(':jpush-react-native')
    compile project(':jcore-react-native')
    compile "com.facebook.react:react-native:+"  // From node_modules
}

在3中修改如下:

 
    

    
        ...
        
        
        
    

打开MainApplication.java,修改如下:

@Override
        protected List getPackages() {
            return Arrays.asList(
                    new MainReactPackage(),
                    new JPushPackage(false,false)
            );
        }

你可能感兴趣的:(react-native整合极光推送)