File tree Expand file tree Collapse file tree 3 files changed +48
-8
lines changed
android/src/main/java/com/uiwjs/react/wechat Expand file tree Collapse file tree 3 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,15 @@ https://uiwjs.github.io/react-native-wechat/apple-app-site-association
54
54
55
55
</details >
56
56
57
+ <details >
58
+ <summary >iOS: -canOpenURL: failed for URL: "weixin://".</summary >
59
+
60
+ > ```
61
+ > -canOpenURL: failed for URL: "weixin://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
62
+ > ```
63
+
64
+ </details>
65
+
57
66
<details>
58
67
<summary>iOS: RCTBridge required dispatch_sync to load RCTDevLoadingView.</summary>
59
68
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public String getName() {
29
29
public void registerApp (String appid , Promise promise ) {
30
30
try {
31
31
this .appId = appid ;
32
- api = WXAPIFactory .createWXAPI (reactContext .getApplicationContext (), appid , true );
32
+ api = WXAPIFactory .createWXAPI (reactContext .getApplicationContext (), null , false );
33
33
promise .resolve (api .registerApp (appid ));
34
34
} catch (Exception e ) {
35
35
promise .reject ("-1" , e .getMessage ());
@@ -47,5 +47,29 @@ public void getApiVersion(Promise promise) {
47
47
promise .reject ("-1" , e .getMessage ());
48
48
}
49
49
}
50
+ @ ReactMethod
51
+ public void isWXAppInstalled (Promise promise ) {
52
+ try {
53
+ if (api == null ) {
54
+ throw new Exception (NOT_REGISTERED );
55
+ }
56
+ promise .resolve (api .isWXAppInstalled ());
57
+ } catch (Exception e ) {
58
+ promise .reject ("-1" , e .getMessage ());
59
+ }
60
+ }
61
+
62
+ @ ReactMethod
63
+ public void isWXAppSupportApi (Promise promise ) {
64
+ try {
65
+ if (api == null ) {
66
+ throw new Exception (NOT_REGISTERED );
67
+ }
68
+ int wxSdkVersion = api .getWXAppSupportAPI ();
69
+ promise .resolve (wxSdkVersion );
70
+ } catch (Exception e ) {
71
+ promise .reject ("-1" , e .getMessage ());
72
+ }
73
+ }
50
74
51
75
}
Original file line number Diff line number Diff line change @@ -9,12 +9,19 @@ export default class App extends Component {
9
9
version : null ,
10
10
} ;
11
11
async componentDidMount ( ) {
12
- const isInstall = await Wechat . isWXAppInstalled ( ) ;
13
- const isWXAppSupportApi = await Wechat . isWXAppSupportApi ( ) ;
14
- const version = await Wechat . getApiVersion ( ) ;
15
- this . setState ( {
16
- isInstall, isWXAppSupportApi, version
17
- } ) ;
12
+ try {
13
+ const reg = await Wechat . registerApp ( 'wxd930ea5d5a258f4f' ) ;
14
+ console . log ( 'reg:' , reg ) ;
15
+ const isInstall = await Wechat . isWXAppInstalled ( ) ;
16
+ const isWXAppSupportApi = await Wechat . isWXAppSupportApi ( ) ;
17
+ const version = await Wechat . getApiVersion ( ) ;
18
+ console . log ( 'version:' , version )
19
+ this . setState ( {
20
+ isInstall, isWXAppSupportApi, version
21
+ } ) ;
22
+ } catch ( error ) {
23
+ console . log ( 'error>' , error ) ;
24
+ }
18
25
}
19
26
render ( ) {
20
27
const { isInstall, isWXAppSupportApi, version } = this . state ;
@@ -29,7 +36,7 @@ export default class App extends Component {
29
36
< Text style = { styles . instructions } >
30
37
当前微信的版本< Text style = { { color : isWXAppSupportApi ? 'green' : 'red' } } > { isWXAppSupportApi ? '支持' : '不支持' } </ Text > OpenApi
31
38
</ Text >
32
- < Text > { version } </ Text >
39
+ < Text > - v { version } </ Text >
33
40
</ Text >
34
41
</ View >
35
42
</ SafeAreaView >
You can’t perform that action at this time.
0 commit comments