1.1.0 • Published 6 years ago

tm-react-native-pgy-sdk v1.1.0

Weekly downloads
10
License
-
Repository
-
Last release
6 years ago

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

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-pgy-sdk and add RNPgySdk.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNPgySdk.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. 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 the getPackages() method
  1. 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')
  2. 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

Read it! :D

  1. In Visual Studio add the RNPgySdk.sln in node_modules/react-native-pgy-sdk/windows/RNPgySdk.sln folder to their solution, reference from their app.
  2. Open up your MainPage.cs app
  • Add using Pgy.Sdk.RNPgySdk; to the usings at the top of the file
  • Add new RNPgySdkPackage() to the List<IReactPackage> returned by the Packages method

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(); }