导入组件
import Communications from 'react-native-communications'
<View style={Styles.container}>
<Header center={'测试电话'} navigator={this.props.navigator} />
<TouchableOpacity style={{ height: 40, marginTop: 40 }}
onPress={() => {
Communications.phonecall('10086', false);
}}>
<Text>调用系统打电话功能</Text>
</TouchableOpacity>
<TouchableOpacity style={{ height: 40, marginTop: 40 }}
onPress={() => {
Communications.text('10086', '要发送的内容');
Communications.textWithoutEncoding('10086', '要发送的内容encoding');//这种方法需要将内容encoding
}}>
<Text>调用系统发短信功能</Text>
</TouchableOpacity>
<TouchableOpacity style={{ height: 40, marginTop: 40 }}
onPress={() => {
Communications.email(['emailAddress1', 'emailAddress2'], null, null, 'My Subject', 'My body text')
}}>
<Text>调用系统发邮件功能</Text>
</TouchableOpacity>
<TouchableOpacity style={{ height: 40, marginTop: 40 }}
onPress={() => {
Communications.web('https://github.com/facebook/react-native')
}}>
<Text>调用系统打开网页功能</Text>
</TouchableOpacity>
</View>
该博客展示了使用React Native调用系统功能的代码示例。通过导入Communications组件,实现了调用系统打电话、发短信、发邮件和打开网页的功能,分别给出了相应的代码及触发操作。
5543

被折叠的 条评论
为什么被折叠?



