1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

feat: Add openWXApp props.

This commit is contained in:
jaywcjlove
2020-08-05 12:42:05 +08:00
parent 864d940513
commit edd515f42b
6 changed files with 67 additions and 17 deletions

View File

@@ -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>
);

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -22,7 +22,7 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="example" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Wechat 微信" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="0.0" y="202" width="375" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>