Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permision denied before send SMS in android #16

Open
ajiehatajie opened this issue Sep 14, 2018 · 3 comments
Open

Permision denied before send SMS in android #16

ajiehatajie opened this issue Sep 14, 2018 · 3 comments

Comments

@ajiehatajie
Copy link

ajiehatajie commented Sep 14, 2018

How check permission before send SMS ?
because log is error if permissions denied in android 7.

@ajiehatajie ajiehatajie changed the title Permision send SMS in android Permision denied before send SMS in android Sep 14, 2018
@olbesp
Copy link

olbesp commented Dec 28, 2018

@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);
  }
};

@briankabiro
Copy link
Owner

Thanks for this. @olbesp. Hopefully, I'll get to integrating this into the docs and maybe getting the package to fail gracefully.

Bilal-Abdeen added a commit to Bilal-Abdeen/permission-check-example that referenced this issue Apr 23, 2021
I added a permission check to the example code. 
briankabiro#16
@Bilal-Abdeen
Copy link

I created PR #84, which adds the code from @olbesp to the example code, which is in the readme file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants