android permission util
callback(err,res) : 回调
- err : null
- res : 返回的联系人信息
callback(err,res) : 回调
- err : null
- res : 返回的通话记录信息
$ npm install rnpm -g
$ npm install --save react-native-permission-manager
$ rnpm link react-native-permission-manager
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
ToastAndroid
} from 'react-native';
import PermissionManager from 'react-native-permission-manager';
class Per extends Component {
contact(){
PermissionManager.getAll((err,res) => {
ToastAndroid.show(JSON.stringify(res),ToastAndroid.LONG);
});
}
calllog(){
PermissionManager.getCallLog((err,res) => {
ToastAndroid.show(JSON.stringify(res),ToastAndroid.LONG);
});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.instructions} onPress={this.contact}>
获取联系人
</Text>
<Text style={styles.instructions} onPress={this.calllog}>
获取通话记录
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
instructions: {
fontSize: 20,
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('Per', () => Per);