如何使用API​​"addPlan"在iOS设备中启用e-sim配置文件

Nic*_*ick 8 cellular-network entitlements ios core-telephony swift

在搜索到处后,我发现有一种方法可以使用以下API在iPhone中添加eSIM

func addPlan(with: CTCellularPlanProvisioningRequest, completionHandler: (CTCellularPlanProvisioningAddPlanResult) -> Void)
Run Code Online (Sandbox Code Playgroud)

我不知道为什么但是完成处理程序没有返回CTCellularPlanProvisioningAddPlanResult的结果 只是打印以下错误.

Domain=NSCocoaErrorDomain Code=4099 "The connection to service named
com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo=
{NSDebugDescription=The connection to service named
com.apple.commcenter.coretelephony.xpc was invalidated.
Run Code Online (Sandbox Code Playgroud)

我想知道这个API是如何工作的,你可以在下面看到我的代码

let ctpr = CTCellularPlanProvisioningRequest()
ctpr.address = "SMDP+"
ctpr.confirmationCode = ""
ctpr.eid = ""
ctpr.iccid = ""

let ctcp =  CTCellularPlanProvisioning()
ctcp.addPlan(with: ctpr) { (result) in
    print(result)
}
Run Code Online (Sandbox Code Playgroud)

我正在使用CoreTelephony框架

任何帮助都会被批评

在检查其他应用程序后,我发现GigSky正在做同样的事情,有谁知道他们在做什么?

更新:

截至目前,我在下面找到了权利请求URL检查

https://developer.apple.com//contact/request/esim-access-entitlement

我要求,但苹果没有回应.

Nic*_*ick 6

通过此过程,您可以将 eSIM 功能集成到您的 iOS 应用程序中。

第1步

使用您的开发者帐户请求eSIM 授权 从这里请求

第2步

Apple 将在一段时间后批准该权利(对我来说需要几个月的时间)您可以从您的应用程序配置文件设置中检查 Apple 是否批准了该权利 应用配置文件设置(证书管理器)

第 3 步

下载应用程序开发和分发配置文件(通过选择 eSIM 授权作为第 2 步)。

第四步

使用以下键和值更新您的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/>
Run Code Online (Sandbox Code Playgroud)

第 5 步(可能是可选的)

使用以下键和值更新您的{appname}.entitlements

<key>com.apple.CommCenter.fine-grained</key>
<array>
    <string>public-cellular-plan</string>
</array> 
Run Code Online (Sandbox Code Playgroud)

步骤 6添加 eSIM 配置文件的代码

 let ctpr = CTCellularPlanProvisioningRequest()
 let ctpr = CTCellularPlanProvisioningRequest()
 ctpr.address = "Your eSIM profile address"
 ctpr.matchingID = "Confirmation id"

 if #available(iOS 12.0, *) {
        let ctcp =  CTCellularPlanProvisioning()
        ctcp.addPlan(with: ctpr) { (result) in
            switch result {
            case .unknown:
                self.showGenericSingleButtonCustomAlert(description: "Sorry unknown error")
            case .fail:
                self.showGenericSingleButtonCustomAlert(description: "Oops! something went wrong")
            case .success:
                self.showGenericSingleButtonCustomAlert(description: "Yay! eSIM installed successfully")
            @unknown default:
                self.showGenericSingleButtonCustomAlert(description: "Oops! something went wrong")
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)