iOS eSIM开发步骤
申请eSIMAPI使用权限
配置项目
使用eSIMAPI
一.申请eSIMAPI使用权限
申请地址:
https://developer.apple.com/contact/request/esim-access-entitlement
申请通过后在开发者后台会出现如下选项:
二.配置项目
info.plist
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>spi</string>
<string>sim-authentication</string>
<string>identity</string>
</array>
<key>com.apple.wlan.authentication</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>apple</string>
<string>com.apple.identities</string>
<string>com.apple.certificates</string>
</array>
<key>com.apple.private.system-keychain</key>
<true/>
设置支持运营商列表
http://www.mcc-mnc.com
经测试 <array>中可以没有内容(添加MCC/MNC的目的还不知道是为了什么,知道的同学可以指点一下),但一定要有CarrierDescriptors这个key
否则这个方法 [[CTCellularPlanProvisioning new] supportsCellularPlan] 不会去请求Apple服务器,一直返回false。
<key>CarrierDescriptors</key>
<array>
<dict>
<key>MCC</key>
<string>460</string>
<key>MNC</key>
<string>00</string>
</dict>
</array>
{appname}.entitlements
<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>public-cellular-plan</string>
</array>
重新生成包含eSIM Entitlements的profile
三.使用eSIMAPI
检测设备是否支持eSIM
+ (BOOL)supportsCellularPlan{
if (@available(iOS 12.0, *)) {
return [[CTCellularPlanProvisioning new] supportsCellularPlan];
} else {
return NO;
}
}
下载安装eSIM配置
+ (void)addPlanWithAddress:(NSString*)address matchingID:(NSString*)matchingID confirmationCode:(NSString*)confirmationCode completionHandler:(void (^)(CTCellularPlanProvisioningAddPlanResult result))completionHandler API_AVAILABLE(ios(12.0)){
CTCellularPlanProvisioningRequest *provisioningRequest = [CTCellularPlanProvisioningRequest new];
provisioningRequest.address = address;
provisioningRequest.matchingID = matchingID;
provisioningRequest.confirmationCode = confirmationCode;
[[CTCellularPlanProvisioning new] addPlanWith:provisioningRequest completionHandler:^(CTCellularPlanProvisioningAddPlanResult result) {
completionHandler(result);
switch (result) {
case CTCellularPlanProvisioningAddPlanResultUnknown:
NSLog(@"Unknown");
break;
case CTCellularPlanProvisioningAddPlanResultFail:
NSLog(@"Fail");
break;
case CTCellularPlanProvisioningAddPlanResultSuccess:
NSLog(@"Success");
break;
}
}];
}
eSIM安装流程图
eSIM激活码规则
安装流程以及效果截图