2020-07-31 14:47:29 +08:00
|
|
|
|
import React, { Component } from 'react';
|
2020-08-01 18:05:40 +08:00
|
|
|
|
import { Platform, SafeAreaView, StyleSheet, Text, View } from 'react-native';
|
2020-08-01 19:44:52 +08:00
|
|
|
|
import Wechat from '@uiw/react-native-wechat';
|
2020-07-31 14:47:29 +08:00
|
|
|
|
|
2020-08-01 18:05:40 +08:00
|
|
|
|
export default class App extends Component {
|
2020-07-31 14:47:29 +08:00
|
|
|
|
state = {
|
2020-08-01 19:59:12 +08:00
|
|
|
|
isInstall: false,
|
|
|
|
|
isWXAppSupportApi: false,
|
2020-08-02 02:04:01 +08:00
|
|
|
|
version: null,
|
2020-07-31 14:47:29 +08:00
|
|
|
|
};
|
2020-08-01 19:44:52 +08:00
|
|
|
|
async componentDidMount() {
|
|
|
|
|
const isInstall = await Wechat.isWXAppInstalled();
|
2020-08-01 19:59:12 +08:00
|
|
|
|
const isWXAppSupportApi = await Wechat.isWXAppSupportApi();
|
2020-08-02 02:04:01 +08:00
|
|
|
|
const version = await Wechat.getApiVersion();
|
2020-08-01 19:59:12 +08:00
|
|
|
|
this.setState({
|
2020-08-02 02:04:01 +08:00
|
|
|
|
isInstall, isWXAppSupportApi, version
|
2020-08-01 19:59:12 +08:00
|
|
|
|
});
|
2020-07-31 14:47:29 +08:00
|
|
|
|
}
|
|
|
|
|
render() {
|
2020-08-02 02:04:01 +08:00
|
|
|
|
const { isInstall, isWXAppSupportApi, version } = this.state;
|
2020-07-31 14:47:29 +08:00
|
|
|
|
return (
|
2020-08-01 18:05:40 +08:00
|
|
|
|
<SafeAreaView style={{ flex: 1 }}>
|
|
|
|
|
<View style={styles.container}>
|
|
|
|
|
<Text style={styles.welcome}>☆Wechat Example☆</Text>
|
2020-08-01 19:59:12 +08:00
|
|
|
|
<Text>
|
|
|
|
|
<Text style={styles.instructions}>
|
|
|
|
|
<Text style={{color: isInstall ? 'green' : 'red'}}>{isInstall ? '有' : '没有'}</Text>安装微信,
|
|
|
|
|
</Text>
|
|
|
|
|
<Text style={styles.instructions}>
|
|
|
|
|
当前微信的版本<Text style={{color: isWXAppSupportApi ? 'green' : 'red'}}>{isWXAppSupportApi ? '支持' : '不支持'}</Text> OpenApi
|
|
|
|
|
</Text>
|
2020-08-02 02:04:01 +08:00
|
|
|
|
<Text>{version}</Text>
|
2020-08-01 19:59:12 +08:00
|
|
|
|
</Text>
|
2020-08-01 18:05:40 +08:00
|
|
|
|
</View>
|
|
|
|
|
</SafeAreaView>
|
2020-07-31 14:47:29 +08:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
container: {
|
|
|
|
|
flex: 1,
|
2020-08-01 18:05:40 +08:00
|
|
|
|
// justifyContent: 'center',
|
2020-07-31 14:47:29 +08:00
|
|
|
|
alignItems: 'center',
|
|
|
|
|
backgroundColor: '#F5FCFF',
|
|
|
|
|
},
|
|
|
|
|
welcome: {
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
margin: 10,
|
|
|
|
|
},
|
|
|
|
|
instructions: {
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
color: '#333333',
|
|
|
|
|
marginBottom: 5,
|
|
|
|
|
},
|
|
|
|
|
});
|