Skip to content

Commit f40169a

Browse files
hengheng
authored andcommitted
init
0 parents  commit f40169a

File tree

8 files changed

+144
-0
lines changed

8 files changed

+144
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/build
2+
.DS_Store
3+
proguard-rules.pro
4+
wechat.iml

build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.2"
6+
7+
defaultConfig {
8+
minSdkVersion 16
9+
targetSdkVersion 23
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
compile fileTree(include: ['*.jar'], dir: 'libs')
23+
compile 'com.facebook.react:react-native:0.16.1'
24+
}

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var React = require('react-native');
2+
3+
var { NativeModules } = React;
4+
5+
module.exports = NativeModules.WeChatAndroid;

libs/libammsdk.jar

146 KB
Binary file not shown.

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "react-native-wechat-android",
3+
"version": "1.0.0",
4+
"description": "the wechat util for android",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/beefe/react-native-wechat-android.git"
12+
},
13+
"keywords": [
14+
"react-native-wechat",
15+
"react-native-wechat-android"
16+
],
17+
"author": "heng",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/beefe/react-native-wechat-android/issues"
21+
},
22+
"homepage": "https://github.com/beefe/react-native-wechat-android#readme"
23+
}

src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.heng.wechat">
3+
4+
5+
</manifest>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.heng.wechat;
2+
3+
import com.facebook.react.bridge.Callback;
4+
import com.facebook.react.bridge.ReactApplicationContext;
5+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
6+
import com.facebook.react.bridge.ReactMethod;
7+
import com.tencent.mm.sdk.modelmsg.SendAuth;
8+
import com.tencent.mm.sdk.openapi.IWXAPI;
9+
import com.tencent.mm.sdk.openapi.WXAPIFactory;
10+
11+
/**
12+
* Created by heng on 15/12/10.
13+
*/
14+
public class WeChatModule extends ReactContextBaseJavaModule {
15+
16+
public static final String REACT_MODULE_NAME = "WeChatAndroid";
17+
18+
public static IWXAPI wxApi = null;
19+
public static ReactApplicationContext reactApplicationContext;
20+
21+
public WeChatModule(ReactApplicationContext reactContext) {
22+
super(reactContext);
23+
WeChatModule.reactApplicationContext = reactContext;
24+
}
25+
26+
@Override
27+
public String getName() {
28+
return REACT_MODULE_NAME;
29+
}
30+
31+
@ReactMethod
32+
public void registerApp(String appId) {
33+
WeChatModule.wxApi = WXAPIFactory.createWXAPI(getReactApplicationContext(),appId, true);
34+
WeChatModule.wxApi.registerApp(appId);
35+
}
36+
37+
@ReactMethod
38+
public void isWXAppInstalled(Callback callback) {
39+
callback.invoke(WeChatModule.wxApi.isWXAppInstalled());
40+
}
41+
42+
@ReactMethod
43+
public void sendAuthRequest(String state) {
44+
SendAuth.Req req = new SendAuth.Req();
45+
req.scope = "snsapi_userinfo";
46+
req.state = state;
47+
WeChatModule.wxApi.sendReq(req);
48+
}
49+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.heng.wechat;
2+
3+
import com.facebook.react.ReactPackage;
4+
import com.facebook.react.bridge.JavaScriptModule;
5+
import com.facebook.react.bridge.NativeModule;
6+
import com.facebook.react.bridge.ReactApplicationContext;
7+
import com.facebook.react.uimanager.ViewManager;
8+
9+
import java.util.ArrayList;
10+
import java.util.Collections;
11+
import java.util.List;
12+
13+
/**
14+
* Created by heng on 15/12/10.
15+
*/
16+
public class WeChatPackage implements ReactPackage {
17+
18+
@Override
19+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
20+
List<NativeModule> list = new ArrayList<>();
21+
list.add(new WeChatModule(reactContext));
22+
return list;
23+
}
24+
25+
@Override
26+
public List<Class<? extends JavaScriptModule>> createJSModules() {
27+
return Collections.emptyList();
28+
}
29+
30+
@Override
31+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
32+
return Collections.emptyList();
33+
}
34+
}

0 commit comments

Comments
 (0)