feat(Android): Add registerApp props.
This commit is contained in:
parent
b3a4a328cc
commit
f1d0bc8c0d
@ -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) {
|
||||
|
@ -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>
|
||||
|
@ -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
1
index.d.ts
vendored
@ -1,6 +1,7 @@
|
||||
|
||||
/**
|
||||
* 向微信注册应用
|
||||
* 必须先注册应用,在 Android 后面的调用才会起作用
|
||||
* @param appid 通过微信开放平台,[获取appid](https://open.weixin.qq.com/)
|
||||
* @param universalLink Universal Link(通用链接)是苹果在 iOS9 推出的,一种能够方便的通过传统 HTTPS 链接来启动 APP 的功能,可以使用相同的网址打开网址和 APP。
|
||||
*/
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user