odemolliens / react-native-sim-cards-manager

React Native plugin to manage Sim card(s) & eSim
MIT License
67 stars 29 forks source link

getSimCardsError #10

Closed bachbonglong closed 2 years ago

bachbonglong commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

Can you test it?

odemolliens commented 2 years ago

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

Can you test it?