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

getSimCardsError #10

Closed
bachbonglong opened this issue Apr 25, 2022 · 5 comments
Closed

getSimCardsError #10

bachbonglong opened this issue Apr 25, 2022 · 5 comments

Comments

@bachbonglong
Copy link

I ran demo source and when I GET SIM CARDS it return getSimCardsError with message:

Something goes wrong to getch simcards:getDeviceId: The user ****** does not meet the requirements to access device identifiers

Pls help me

@odemolliens
Copy link
Owner

odemolliens commented Apr 25, 2022

On which version of Android?

Can you try to edit the AndroidManifest file of the sample like this:
https://github.com/odemolliens/react-native-sim-cards-manager/blob/develop/example/android/app/src/main/AndroidManifest.xml#L5

and let me know if it's working better?

@bachbonglong
Copy link
Author

On which version of Android?

Can you try to edit the AndroidManifest file of the sample like this: https://github.com/odemolliens/react-native-sim-cards-manager/blob/develop/example/android/app/src/main/AndroidManifest.xml#L5

and let me know if it's working better?

Version Android 11
Device : Realme x2 Pro

Yes. I added uses-permission android:name="android.permission.READ_PHONE_STATE" but nothing request Permission.

@odemolliens
Copy link
Owner

odemolliens commented Apr 25, 2022

Nothing request permission because we don't manage it from the native side.

To handle that, we will have to do something like this at the library level or directly in the sample:

import { Platform, PermissionsAndroid } from 'react-native';

async function requestCellularNetworkPermission() {
  if (Platform.OS == 'android') {
    try {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE,
        {
          title: 'App Permission',
          message:
            'App needs access get information' +
            'of your cellular network',
          buttonNeutral: 'Ask Me Later',
          buttonNegative: 'Cancel',
          buttonPositive: 'OK',
        },
      );
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        console.log('Access allowed');
        // Call the bridge
      } else {
        console.log('Access denied');
      }
    } catch (err) {
      console.warn(err);
    }
  } else {
    console.log('Access allowed');
    // Call the bridge
  }
}

We will think about it and release a new version this week

@odemolliens
Copy link
Owner

odemolliens commented Apr 27, 2022

@bachbonglong, a new version 1.0.2 has been released, taking care of the android permission

Can you test it?

@odemolliens
Copy link
Owner

@bachbonglong, a new version has been released, taking care of the android permission

Can you test it?

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