React Native 集成Android友盟推送过程
16lz
2021-01-24
配置
新版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配置文件的版本信息
- android开发环境类错误
- 提示Android(安卓)requires compiler compliance level 5.0 or 6
- Android版本更新实例详解
- 解决办法:Android(安卓)Studio报错“Error:Failed to open zip fi
- Android(安卓)8.0通知不显示
- Android(安卓)App 隐藏显示标题栏、状态栏、导航栏
- Android当前版本使用分布情况
- Libcurl库移植指南(上)--OpenSSL库移植