react-native-get-sms-android
react-native-get-sms-android copied to clipboard
Permision denied before send SMS in android
How check permission before send SMS ? because log is error if permissions denied in android 7.
@ajiehatajie try this:
import { PermissionsAndroid, Alert } from 'react-native';
async componentDidMount() {
try {
let granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.SEND_SMS, {
title: 'Send SMS',
message: 'Need access to send sms',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('SEND_SMS permissions granted', granted);
} else {
Alert.alert('SEND_SMS permissions denied');
console.log('SEND_SMS permissions denied');
}
} catch (err) {
Alert.alert(err);
}
};
Thanks for this. @olbesp. Hopefully, I'll get to integrating this into the docs and maybe getting the package to fail gracefully.
I created PR #84, which adds the code from @olbesp to the example code, which is in the readme file.