1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

feat(Android): Add registerApp props.

This commit is contained in:
jaywcjlove 2020-08-01 21:26:56 +08:00
parent b3a4a328cc
commit f1d0bc8c0d
5 changed files with 24 additions and 5 deletions

View File

@ -73,6 +73,10 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
// SDK
// Android Studio环境下gradle形式jcenter使gradle来编译SDK
// build.gradle文件中
implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
}
def configureReactNativePom(def pom) {

View File

@ -1,4 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uiwjs.react.wechat">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>

View File

@ -4,10 +4,15 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.Promise;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.tencent.mm.opensdk.openapi.IWXAPI;
public class RNWechatModule extends ReactContextBaseJavaModule {
private final ReactApplicationContext reactContext;
private String appId;
private IWXAPI api = null;
public RNWechatModule(ReactApplicationContext reactContext) {
super(reactContext);
@ -20,8 +25,13 @@ public class RNWechatModule extends ReactContextBaseJavaModule {
}
@ReactMethod
public void sampleMethod(String stringArgument, int numberArgument, Callback callback) {
// TODO: Implement some actually useful functionality
callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument);
public void registerApp(String appid, Promise promise) {
try {
this.appId = appid;
api = WXAPIFactory.createWXAPI(reactContext.getApplicationContext(), appid, true);
promise.resolve(api.registerApp(appid));
} catch (Exception e) {
promise.reject("-1", e.getMessage());
}
}
}

1
index.d.ts vendored
View File

@ -1,6 +1,7 @@
/**
*
* Android
* @param appid [appid](https://open.weixin.qq.com/)
* @param universalLink Universal Link() iOS9 便 HTTPS APP 使 APP
*/

View File

@ -1,6 +1,6 @@
{
"name": "@uiw/react-native-wechat",
"title": "@uiw/react Native Wechat",
"title": "React Native Wechat",
"version": "1.0.0",
"description": "React Native 包使用微信分享、登录、收藏、支付等功能。",
"main": "index.js",