feat: Add openWXApp props.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Platform, SafeAreaView, StyleSheet, Text, View } from 'react-native';
|
||||
import { Platform, Button, SafeAreaView, StyleSheet, Text, View } from 'react-native';
|
||||
import Wechat from '@uiw/react-native-wechat';
|
||||
|
||||
export default class App extends Component {
|
||||
@@ -10,19 +10,26 @@ export default class App extends Component {
|
||||
};
|
||||
async componentDidMount() {
|
||||
try {
|
||||
const reg = await Wechat.registerApp('wxd930ea5d5a258f4f');
|
||||
console.log('reg:', reg);
|
||||
const reg = await Wechat.registerApp('wx500b695a47bd364b', 'https://uiwjs.github.io/react-native-wechat/apple-app-site-association');
|
||||
const isInstall = await Wechat.isWXAppInstalled();
|
||||
const isWXAppSupportApi = await Wechat.isWXAppSupportApi();
|
||||
const version = await Wechat.getApiVersion();
|
||||
console.log('version:', version)
|
||||
console.log('version:', version);
|
||||
this.setState({
|
||||
isInstall, isWXAppSupportApi, version
|
||||
isInstall,
|
||||
isWXAppSupportApi,
|
||||
version
|
||||
});
|
||||
} catch (error) {
|
||||
console.log('code>', error.code);
|
||||
console.log('message>', error.message);
|
||||
console.log('error>', error);
|
||||
}
|
||||
}
|
||||
openWXApp = async () => {
|
||||
const isOpen = await Wechat.openWXApp();
|
||||
console.log('isOpen:', isOpen);
|
||||
}
|
||||
render() {
|
||||
const { isInstall, isWXAppSupportApi, version } = this.state;
|
||||
return (
|
||||
@@ -31,13 +38,18 @@ export default class App extends Component {
|
||||
<Text style={styles.welcome}>☆Wechat Example☆</Text>
|
||||
<Text>
|
||||
<Text style={styles.instructions}>
|
||||
<Text style={{color: isInstall ? 'green' : 'red'}}>{isInstall ? '有' : '没有'}</Text>安装微信,
|
||||
<Text style={{color: isInstall ? 'green' : 'red'}}>{isInstall ? '已经' : '没有'}</Text>安装微信,
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
当前微信的版本<Text style={{color: isWXAppSupportApi ? 'green' : 'red'}}>{isWXAppSupportApi ? '支持' : '不支持'}</Text> OpenApi
|
||||
</Text>
|
||||
<Text> - v{version}</Text>
|
||||
</Text>
|
||||
<Button
|
||||
onPress={this.openWXApp}
|
||||
title="打开微信 APP"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
Reference in New Issue
Block a user