tm-react-native-pgy-sdk
v1.1.0
Published
## Getting started
Downloads
35
Readme
react-native-pgy-sdk
Getting started
$ npm install react-native-pgy-sdk --save
Mostly automatic installation
$ react-native link react-native-pgy-sdk
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-pgy-sdkand addRNPgySdk.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNPgySdk.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNPgySdkPackage;to the imports at the top of the file - Add
new RNPgySdkPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':react-native-pgy-sdk' project(':react-native-pgy-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pgy-sdk/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-pgy-sdk')
1.0.0版本:在allProjects下的repositories中加入: maven { url "https://raw.githubusercontent.com/Pgyer/mvn_repo_pgyer/master" } 这个是下载蒲公英sdk的 1.1.0版本不需要。
Windows
- In Visual Studio add the
RNPgySdk.slninnode_modules/react-native-pgy-sdk/windows/RNPgySdk.slnfolder to their solution, reference from their app. - Open up your
MainPage.csapp
- Add
using Pgy.Sdk.RNPgySdk;to the usings at the top of the file - Add
new RNPgySdkPackage()to theList<IReactPackage>returned by thePackagesmethod
JS代码中主动调用检测更新: import {checkUpdate} from 'react-native-pgy-sdk';
checkUpdate(appKey);//iOS平台上需要传appKey,android的appKey是配置在AndroidMainfest.xml中
iOS从后台返回到前台检测更新: 在didFinishLaunchingWithOptions 调用: [RNPgySdk startUpdateManagerWithAppId:pgyAppkey];
Android从后台返回到前台检测更新,在MainActivity中加入 @Override protected void onResume() { super.onResume(); PgyManager.startUpdateManager(); }
