React Native eSim激活错误- EMBEDDED_SUBSCRIPTION_RESULT_ERROR无法添加Esim订阅

w9apscun  于 2022-11-17  发布在  React
关注(0)|答案(1)|浏览(111)

配置:-设备:-三星s21 ultra不带sim!操作系统- 12(31 API级别)Package name = com.example.reactnativesimcardsmanager
库参考链接:https://github.com/odemolliens/react-native-sim-cards-manager/tree/develop
对于Android代码:https://github.com/odemolliens/react-native-sim-cards-manager/tree/develop/android/src/main/java/com/reactnativesimcardsmanager
例1设置:当库支持目标版本= 31时,编译版本31。示例目标版本= 30,编译版本30。
结果=当点击激活ESIM获取权限弹出窗口“允许”软件包名称"访问您手机的eUICC配置文件?
点击“允许”后,出现以下错误。“2 EMBEDDED_SUBSCRIPTION_RESULT_ERROR -无法添加Esim订阅”
例2设置:当库支持目标版本= 31时,编译版本31。示例目标版本= 31,编译版本31
结果=当点击激活ESIM获取权限弹出窗口“允许'包名称'访问您的手机的eUICC配置文件”时,出现以下错误。E/错误:3 EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR -由于活动错误为空,无法设置eSim
点击“允许”后,出现以下错误“2 EMBEDDED_SUBSCRIPTION_RESULT_ERROR -无法添加Esim订阅”
参考链接:-https://source.android.com/devices/tech/connect/esim-overview
()..............如果您的Android操作系统是Android 9(API 28)或更早版本,那么您的Android操作系统将无法运行。}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && mgr != null && !mgr.isEnabled()) {
  promise.reject("1", "The device doesn't support a cellular plan (EuiccManager is not available)");
  return;
}

BroadcastReceiver receiver = new BroadcastReceiver() {

  @Override
  public void onReceive(Context context, Intent intent) {
    if (!ACTION_DOWNLOAD_SUBSCRIPTION.equals(intent.getAction())) {
      Log.e("Error", "3 Can't setup eSim du to wrong Intent:" + intent.getAction() + " instead of " + ACTION_DOWNLOAD_SUBSCRIPTION);
      promise.reject("3", "Can't setup eSim du to wrong Intent:" + intent.getAction() + " instead of " + ACTION_DOWNLOAD_SUBSCRIPTION);

      showAlert("Error", "3 Can't setup eSim du to wrong Intent:" + intent.getAction() + " instead of " + ACTION_DOWNLOAD_SUBSCRIPTION);
      return;
    }

    int resultCode = getResultCode();
    if (resultCode == EuiccManager.EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR && mgr != null) {
      try {

        promise.resolve(3);
        PendingIntent callbackIntent = PendingIntent.getBroadcast(mReactContext, 3,
          new Intent(ACTION_DOWNLOAD_SUBSCRIPTION), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
        mgr.startResolutionActivity(mReactContext.getCurrentActivity(), 3, intent, callbackIntent);
      } catch (Exception e) {
        e.printStackTrace();
        Log.e("Error", "3 EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR - Can't setup eSim du to Activity error" + e.getLocalizedMessage());
        promise.reject("3", "EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR - Can't setup eSim du to Activity error" + e.getLocalizedMessage());
        showAlert("Error", "3 EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR - Can't setup eSim du to Activity error" + e.getLocalizedMessage());
      }
    } else if (resultCode == EuiccManager.EMBEDDED_SUBSCRIPTION_RESULT_OK) {
      promise.resolve(true);

      Log.e("Success", "EMBEDDED_SUBSCRIPTION_RESULT_OK");
      showAlert("Success", "Success : EMBEDDED_SUBSCRIPTION_RESULT_OK");
    } else if (resultCode == EuiccManager.EMBEDDED_SUBSCRIPTION_RESULT_ERROR) {

      Log.e("Error", "2 EMBEDDED_SUBSCRIPTION_RESULT_ERROR - Can't add an Esim subscription");
      promise.reject("2", "EMBEDDED_SUBSCRIPTION_RESULT_ERROR - Can't add an Esim subscription");
      showAlert("Error", "2 EMBEDDED_SUBSCRIPTION_RESULT_ERROR - Can't add an Esim subscription");

      int detailedCode = intent.getIntExtra(EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE, 0);
      Log.e("detailedCode", detailedCode+"");

    } else {

      Log.e("Error", "3 Can't add an Esim subscription due to unknown error, resultCode is:" + String.valueOf(resultCode));
      promise.reject("3", "Can't add an Esim subscription due to unknown error, resultCode is:" + String.valueOf(resultCode));
      showAlert("Error", "3 Can't add an Esim subscription due to unknown error, resultCode is:" + String.valueOf(resultCode));
    }
  }
};

mReactContext.registerReceiver(
  receiver,
  new IntentFilter(ACTION_DOWNLOAD_SUBSCRIPTION),
  null,
  null);

DownloadableSubscription sub = DownloadableSubscription.forActivationCode(

  config.getString("confirmationCode"));

PendingIntent callbackIntent = PendingIntent.getBroadcast(
  mReactContext,
  0,
  new Intent(ACTION_DOWNLOAD_SUBSCRIPTION),
  PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);

mgr.downloadSubscription(sub, true, callbackIntent);

}

ovfsdjhp

ovfsdjhp1#

在所有情况下,您收到的detailedCodeoperationCode是什么?我有一个类似的问题,但detailedCode和operationCode从未设置。

相关问题