我需要检查一下,iphone中是否安装了esim。使用react-native创建应用程序。找到使用CTTelephonyNetworkInfo和CTCarrier的react-native-carrier-info
CTTelephonyNetworkInfo和CTCarrier是否可以显示是否安装了esim或有关这方面的一些信息来得出这样的结论?在模拟器上我看不到任何信息
阅读coretelephony,但我不确定是否有用于此任务的本机api,或者哪种api可以帮助我得出这样的结论。
发布于 2019-04-25 02:32:20
我希望这能对你有所帮助:
基本上,您需要创建一个库来访问Objective-C中的本地库吗
1 - npm install -g react-native-create-library
2 - react-native-create-library MyLibrary
3 - npm install在新的库中,您是否实现了对本地库的访问:
#import <React/RCTBridgeModule.h>
@interface NetworkInfo : NSObject <RCTBridgeModule>
@end实施:
// NetworkInfo.m
#import "NetworkInfo.h"
#import <React/RCTLog.h>
@implementation NetworkInfo
// To export a module named NetworkInfo
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location)
{
RCTLogInfo(@"Pretending to create an event %@ at %@", name, location);
}
@end在你的Javascript中:
import {NativeModules} from 'react-native';
var NetworkInfo = NativeModules.NetworkInfo;....your代码
欲了解更多信息,请登录:native-modules-ios。
发布于 2019-09-25 16:09:32
在Swift中,如果您只想检查eSim connectivity ,您可以:
// First, check if the currentRadioAccessTechnology is nil
// It means that no physical Sim card is inserted
let telephonyInfo = CTTelephonyNetworkInfo()
if telephonyInfo.currentRadioAccessTechnology == nil {
// Next, on iOS 12 only, you can check the number of services connected
// With the new serviceCurrentRadioAccessTechnology property
if #available(iOS 12, *) {
if let radioTechnologies =
telephonyInfo.serviceCurrentRadioAccessTechnology, !radioTechnologies.isEmpty {
// One or more radio services has been detected,
// the user has one (ore more) eSim package connected to a network
}
}
}您可以通过在CTCellularPlanProvisioning上使用新的supportsCellularPlan()方法来加强检查。
https://stackoverflow.com/questions/55833207
复制相似问题