我正在申请多项权限。除了接收短信之外,所有工作都正常,其中结果总是'never_ask_again'。
以下是我正在尝试的代码:
_getPermissions = async () => {
try {
const resuts = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
PermissionsAndroid.PERMISSIONS.RECEIVE_SMS,
PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE
]);
if (
resuts[PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION] !==
PermissionsAndroid.RESULTS.GRANTED
) {
alert("Permission not granted. The application may not work properly");
}
if (
resuts[PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE] !==
PermissionsAndroid.RESULTS.GRANTED
) {
alert("Permission not granted. The application may not work properly");
}
if (
resuts[PermissionsAndroid.PERMISSIONS.RECEIVE_SMS] !==
PermissionsAndroid.RESULTS.GRANTED
) {
alert("Permission not granted. The application may not work properly");
}
} catch (err) {
console.warn(err);
}
};
答案 0 :(得分:0)
将此行固定为相反的条件:
if (
resuts[PermissionsAndroid.PERMISSIONS.RECEIVE_SMS] ===
PermissionsAndroid.RESULTS.DENIED
) {
Alert.alert("Permission not granted. The application may not work properly");
}