配置:-设备:-三星s21超无sim!OS-12(31个API级别)包名= com.example.reactnativesimcardsmanager
图书馆参考链接:https://github.com/odemolliens/react-native-sim-cards-manager/tree/develop
案例1设置:当库支持目标版本= 31时,编译版本31。示例Target Version = 30,并编译version 30。
当单击ACTIVATE获得许可时,弹出“允许‘包名’访问您手机的eUICC配置文件吗?
在点击“允许”获得以下错误。“2 EMBEDDED_SUBSCRIPTION_RESULT_ERROR -无法添加Esim订阅”
案例2设置:当库支持目标版本= 31时,编译版本31。示例塔吉特版本= 31和编译版本31
Result=点击激活ESIM获得许可弹出“允许‘包名’访问您的手机的eUICC配置文件?有以下错误。E/ error : 3 EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR -无法将eSim du设置为活动错误null
单击“允许”“获取以下错误”2 EMBEDDED_SUBSCRIPTION_RESULT_ERROR -无法添加Esim订阅“
参考链接:- https://source.android.com/devices/tech/connect/esim-overview
公共无效setupEsim(ReadableMap配置,承诺){ initMgr();if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP_MR1) { promise.reject("0","EuiccManager是不可用的或在Android9 (API 28)“之前);}
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);}
发布于 2022-11-08 16:43:20
在所有情况下,您正在接收的detailedCode和operationCode是什么?我有一个类似的问题,但detailedCode和operationCode从来没有设置过。
https://stackoverflow.com/questions/72067097
复制相似问题