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

react-native-navigation is breaking react-native/PermissionsAndroid #3257

Closed
rcidt opened this issue May 24, 2018 · 2 comments
Closed

react-native-navigation is breaking react-native/PermissionsAndroid #3257

rcidt opened this issue May 24, 2018 · 2 comments

Comments

@rcidt
Copy link

rcidt commented May 24, 2018

Issue Description

react-native-navigation is preventing the onRequestPermissionsResult method in the application's MainActivity from being called.

This is causing facebook/react-native#17985

Steps to Reproduce / Code Snippets / Screenshots

(copied from facebook/react-native#17)
We have a Camera component and it should check for the Camera permission before mounting.

In my app's AndroidManifest.xml I have the line, along with many other permissions:

<uses-permission android:name="android.permission.CAMERA"/>
In our component's componentDidMount() we call a function that should return true if we have permission and false if we do not have, here is the relevant snippet of the function:

if (Platform.OS === 'android') {
const isGranted = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.CAMERA);
      if (isGranted) {
        return true;
      }
      try {
        console.log('before request');
        const granted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.CAMERA,
          {
            title: 'Dialog Title',
            message: 'Dialog Message',
          }
        );
        console.log('after request');
        return granted === PermissionsAndroid.RESULTS.GRANTED;
      } catch (err) {
        console.log('error');
        console.log(err);
      }
}

Expected Behavior

A dialog with my title and message should appear, if the user clicks on "Allow", the promise should resolve and my component should render as expected.


Environment

  • React Native Navigation version: 1.1.408
  • React Native version: 0.49.3
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): API > 23
@rcidt rcidt closed this as completed May 24, 2018
@rcidt rcidt reopened this May 24, 2018
@rcidt rcidt closed this as completed May 25, 2018
@vanlooverenkoen
Copy link

What did you do to fix this issue?

@rcidt
Copy link
Author

rcidt commented Jun 7, 2018

@vanlooverenkoen I updated to the latest version of react-native

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

2 participants