react-native-wechat-android
Advanced tools
Comparing version 2.0.0 to 2.0.1
99
HELP.md
@@ -1,85 +0,30 @@ | ||
# 本文档针对react-native版本为0.17及以下 | ||
## 建议用[Android Studio](http://developer.android.com/sdk/index.html)(需要翻墙)打开android 项目来修改,不然编译容易出错。 | ||
### 添加步骤: | ||
* [安装npm包](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#第一步--安装npm包) | ||
* [更新settings.gradle](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#第二步--更新settingsgradle) | ||
* [更新build.gradle](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#第三步--更新app的buildgradle) | ||
* [注册包](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#第四步--注册包) | ||
* [添加微信sdk](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#第五步--添加微信sdk) | ||
* [添加微信回调类的实现](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#第六步--添加微信回调类的实现) | ||
* [在js文件中使用](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#第七步--在你的js文件中使用) | ||
* [安装rnpm包](#安装rnpm包)(已安装rnpm包的请忽略本步骤) | ||
* [安装npm包](#安装npm包) | ||
* [添加link](#添加link) | ||
* [添加微信sdk](#添加微信sdk)(如果你的react-native >= 0.18.0,请忽略本步骤) | ||
* [添加微信回调类](#添加微信回调类) | ||
* [开始使用](#开始使用) | ||
#### 第一步 : 安装npm包 | ||
#### 安装rnpm包 | ||
```shell | ||
npm install --save react-native-wechat-android | ||
$ npm install rnpm -g | ||
``` | ||
#### 第二步 : 更新settings.gradle | ||
```gradle | ||
// 文件路径:android/settings.gradle | ||
... | ||
include ':reactwechat', ':app' | ||
project(':reactwechat').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wechat-android') | ||
// 如果有其他的library,这样添加: | ||
// include ':app' , ':libraryone' , ':librarytwo' , 'more...' | ||
// project(':libraryonename').projectDir = new File(rootProject.projectDir, '../node_modules/libraryonemodule') | ||
// project(':librarytwoname').projectDir = new File(rootProject.projectDir, '../node_modules/librarytwomodule') | ||
// more.. | ||
#### 安装npm包 | ||
```shell | ||
$ npm install --save react-native-wechat-android | ||
``` | ||
#### 第三步 : 更新app的build.gradle | ||
```gradle | ||
// 文件路径:android/app/build.gradle | ||
// file: android/app/build.gradle | ||
... | ||
dependencies { | ||
... | ||
compile project(':reactwechat') | ||
} | ||
#### 添加link | ||
```shell | ||
$ rnpm link react-native-wechat-android | ||
``` | ||
#### 第四步 : 注册包 | ||
```java | ||
... | ||
import com.heng.wechat.WeChatPackage; // 导入类 | ||
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler { | ||
private ReactInstanceManager mReactInstanceManager; | ||
private ReactRootView mReactRootView; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
mReactRootView = new ReactRootView(this); | ||
mReactInstanceManager = ReactInstanceManager.builder() | ||
.setApplication(getApplication()) | ||
.setBundleAssetName("index.android.bundle") | ||
.setJSMainModuleName("index.android") | ||
.addPackage(new MainReactPackage()) | ||
.addPackage(new WeChatPackage()) // 注册WeChatPackage | ||
.setUseDeveloperSupport(BuildConfig.DEBUG) | ||
.setInitialLifecycleState(LifecycleState.RESUMED) | ||
.build(); | ||
... | ||
} | ||
... | ||
``` | ||
#### 第五步 : 添加微信SDK | ||
#### 添加微信sdk | ||
把wechat/libs/libammsdk.jar复制到android/app/libs文件夹下,或者去微信开放平台的资源中心 点击[Android资源下载](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319167)下载[Android开发工具包](https://res.wx.qq.com/open/zh_CN/htmledition/res/dev/download/sdk/Android2_SDK238f8d.zip) | ||
#### 第六步 : 添加微信回调类的实现 | ||
在你的包名相应目录下创建回调类的目录,例如应用程序的包名为com.heng,在该目录应该为com.heng.wxapi(微信指定的回调路径,不能更改,否则无法获取回调结果),并在该wxapi目录下创建[WXEntryActivity.java](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#wxentryactivityjava-)(微信登录和微信分享的回调类)和[WXPayEntryActivity.java](https://github.com/beefe/react-native-wechat-android/blob/master/HELP.md#wxpayentryactivityjava-)(微信支付的回调类,如果没有微信支付功能不需要此类),均需要继承自Activity(extends Activity),并在AndroidManifest.xml文件中添加如下代码: | ||
#### 添加微信回调类 | ||
在你的包名相应目录下创建回调类的目录,例如应用程序的包名为com.heng,在该目录应该为com.heng.wxapi(微信指定的回调路径,不能更改,否则无法获取回调结果),并在该wxapi目录下创建[WXEntryActivity.java](#wxentryactivityjava)(微信登录和微信分享的回调类)和[WXPayEntryActivity.java](#wxpayentryactivityjava)(微信支付的回调类,如果没有微信支付功能不需要此类),均需要继承自Activity(extends Activity),并在AndroidManifest.xml文件中添加如下代码: | ||
```xml | ||
@@ -105,5 +50,5 @@ ... | ||
##### WXEntryActivity.java : | ||
##### WXEntryActivity.java | ||
```java | ||
package com.loanbear.wxapi; //改为你的包名 package com.xxx.wxapi; | ||
package com.xx.wxapi; // 这里改为你的包名 | ||
@@ -179,6 +124,6 @@ import android.app.Activity; | ||
##### WXPayEntryActivity.java : | ||
##### WXPayEntryActivity.java | ||
```java | ||
package com.loanbear.wxapi; //改为你的包名 package com.xxx.wxapi; | ||
package com.xxx.wxapi; // 这里改为你的包名 | ||
@@ -247,3 +192,3 @@ import android.app.Activity; | ||
#### 第七步 : 在你的JS文件中使用 | ||
#### 开始使用 | ||
@@ -250,0 +195,0 @@ ```javascript |
{ | ||
"name": "react-native-wechat-android", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "the wechat util for android", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# react-native-wechat-android | ||
react-native 的微信SDK辅助包,支持微信登录、微信分享、微信支付。 | ||
## 安装及使用方法 | ||
* [react-native >= 0.18](./HELP-18.md) | ||
* [react-native <= 0.17](./HELP.md) | ||
## [安装及使用方法](./HELP.md) | ||
@@ -8,0 +6,0 @@ ## 提供以下方法 / Method |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
184130
10
276