[英]How to return to app after saving contacts - React Native - react-native-contacts
[英]App Crash while using React-Native-Contacts
我的应用程序在使用任何 react-native-contacts 方法时崩溃。
function getPhoneRecords() {
PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS,
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
]).then(() => {
Contacts.getAll((err, contacts) => {
if (err) {
console.log(err, 'failed to fetch phone Records!');
} else {
setPhoneRecords(contacts);
}
});
});}
这是 function 到 getAllContacts 但每当这个 function 执行我的应用程序崩溃时没有错误。 我该如何解决这个问题? 提前致谢。
如果它在 iOS 上崩溃:
检查您是否更新了 Info.plist 文件。 您必须拥有带有句子值的“隐私 - 联系人使用说明”键。
遵循文档: https://github.com/morenoh149/react-native-contacts#ios-2
如果它在 Android 上崩溃:
检查您是否更新了 AndroidManifest.xml 文件。 您必须请求许可,例如 iOS。
遵循文档:https://github.com/morenoh149/react-native-contacts#permissions
//Try it
const addContact = () => {
PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS,
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
])
Contacts.getAll().then(contacts => {
// console.log('hello',contacts);
setMblContacts(contacts);
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.