react-native-sdk-share
Getting started
$ npm install react-native-sdk-share --save
Mostly automatic installation
$ react-native link react-native-sdk-share
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-sdk-share
and addRNShare.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNShare.a
to 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.library.share.RNSharePackage;
to the imports at the top of the file - Add
new RNSharePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-sdk-share' project(':react-native-sdk-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sdk-share/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-sdk-share')
配置(请参考微信开放平台文档)
Demo
; const weiXinSceneType = session:1timeLine:2 ; //session=1微信好友,timeLine=2微信朋友圈const defaultCallback = { console; }; //默认回调方法const UtilsShare = { ; } { if sceneType === weiXinSceneTypetimeLine ; else if sceneType === weiXinSceneTypesession ; };; UtilsShare; //注册appUtilsShare;
说明
微信开放平台注册安卓平台使用registerApp,iOS使用registerIosWxApp。