File tree Expand file tree Collapse file tree 5 files changed +24
-5
lines changed
java/com/uiwjs/react/wechat Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,10 @@ repositories {
7373dependencies {
7474 // noinspection GradleDynamicVersion
7575 implementation ' com.facebook.react:react-native:+' // From node_modules
76+ // 微信SDK
77+ // Android Studio环境下:已改用gradle形式,发布到jcenter,请开发者使用gradle来编译、更新微信SDK。
78+ // 在build.gradle文件中,添加如下依赖即可:
79+ implementation ' com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
7680}
7781
7882def configureReactNativePom (def pom ) {
Original file line number Diff line number Diff line change 11<manifest xmlns : android =" http://schemas.android.com/apk/res/android"
22 package =" com.uiwjs.react.wechat" >
3-
3+ <uses-permission android : name =" android.permission.INTERNET" />
4+ <uses-permission android : name =" android.permission.ACCESS_NETWORK_STATE" />
5+ <uses-permission android : name =" android.permission.ACCESS_WIFI_STATE" />
6+ <uses-permission android : name =" android.permission.READ_PHONE_STATE" />
7+ <uses-permission android : name =" android.permission.WRITE_EXTERNAL_STORAGE" />
48</manifest >
Original file line number Diff line number Diff line change 44import com .facebook .react .bridge .ReactContextBaseJavaModule ;
55import com .facebook .react .bridge .ReactMethod ;
66import com .facebook .react .bridge .Callback ;
7+ import com .facebook .react .bridge .Promise ;
8+ import com .tencent .mm .opensdk .openapi .WXAPIFactory ;
9+ import com .tencent .mm .opensdk .openapi .IWXAPI ;
710
811public class RNWechatModule extends ReactContextBaseJavaModule {
912
1013 private final ReactApplicationContext reactContext ;
14+ private String appId ;
15+ private IWXAPI api = null ;
1116
1217 public RNWechatModule (ReactApplicationContext reactContext ) {
1318 super (reactContext );
@@ -20,8 +25,13 @@ public String getName() {
2025 }
2126
2227 @ ReactMethod
23- public void sampleMethod (String stringArgument , int numberArgument , Callback callback ) {
24- // TODO: Implement some actually useful functionality
25- callback .invoke ("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument );
28+ public void registerApp (String appid , Promise promise ) {
29+ try {
30+ this .appId = appid ;
31+ api = WXAPIFactory .createWXAPI (reactContext .getApplicationContext (), appid , true );
32+ promise .resolve (api .registerApp (appid ));
33+ } catch (Exception e ) {
34+ promise .reject ("-1" , e .getMessage ());
35+ }
2636 }
2737}
Original file line number Diff line number Diff line change 11
22/**
33 * 向微信注册应用
4+ * 必须先注册应用,在 Android 后面的调用才会起作用
45 * @param appid 通过微信开放平台,[获取appid](https://open.weixin.qq.com/)
56 * @param universalLink Universal Link(通用链接)是苹果在 iOS9 推出的,一种能够方便的通过传统 HTTPS 链接来启动 APP 的功能,可以使用相同的网址打开网址和 APP。
67 */
Original file line number Diff line number Diff line change 11{
22 "name" : " @uiw/react-native-wechat" ,
3- "title" : " @uiw/react Native Wechat" ,
3+ "title" : " React Native Wechat" ,
44 "version" : " 1.0.0" ,
55 "description" : " React Native 包使用微信分享、登录、收藏、支付等功能。" ,
66 "main" : " index.js" ,
You can’t perform that action at this time.
0 commit comments