React Native 集成Android友盟推送过程

配置

新版AndroidStudio AndroidManifest.xml文件分为2个 release版本和debug版本注意都要添加权限

 
    
    
    
    

项目的build.gradle 要添加资源库

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = '28.0.3'
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = '28.0.0'
    }
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/umsdk/release' } //这里
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://dl.bintray.com/umsdk/release' }//这里
    }
}

添加依赖注意根据自己情况增删

    //PushSDK必须依赖基础组件库,所以需要加入对应依赖
    implementation 'com.umeng.umsdk:common:2.0.0'
	//PushSDK必须依赖utdid库,所以需要加入对应依赖
    implementation 'com.umeng.umsdk:utdid:1.1.5.3'
	//PushSDK
    implementation 'com.umeng.umsdk:push:6.0.1'
	//官方React Native的例子里有使用这里面的代码
    implementation 'com.umeng.umsdk:analytics:8.0.0'

js端 具体里面的方法可以查看官方文档

var { NativeModules } = require('react-native');
module.exports = NativeModules.UMAnalyticsModule;
var { NativeModules } = require('react-native');
module.exports = NativeModules.UMAnalyticsModule;
var { NativeModules } = require('react-native');
module.exports = NativeModules.UMAnalyticsModule;

你可能感兴趣的:(android,React,Native)