((eSIM Integration iOS)如何使用API “ addPlan”在iOS设备中启用e-sim配置文件

问题描述 投票:8回答:2

搜索了所有地方之后,我发现有一种使用以下API在iPhone中添加eSIM的方法

func addPlan(with: CTCellularPlanProvisioningRequest, completionHandler: (CTCellularPlanProvisioningAddPlanResult) -> Void)

我不知道为什么,但是完成处理程序不返回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.

我想知道此API的工作原理,您可以在下面看到我的代码

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

let ctcp =  CTCellularPlanProvisioning()
ctcp.addPlan(with: ctpr) { (result) in
    print(result)
}

我正在使用CoreTelephony框架

将提供任何帮助

检查了其他应用程序后,我发现GigSky在做同样的事情,任何人都知道他们的工作吗?

UPDATE:

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

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

我请求,但是苹果没有回应。

ios swift entitlements cellular-network core-telephony
2个回答
3
投票

此API仅适用于运营商。您需要Apple的特殊权利才能在您的应用程序中调用它,否则您将得到您提到的错误。

只是为了澄清有关eSIM的内容;有几种方法可以将eSIM添加到设备:

  • 大多数运营商现在实现的最简单方法是通过扫描设备设置中的QR码,而无需在运营商的应用程序上进行任何开发工作。
  • 另一种方法是使用运营商应用程序安装eSIM配置文件,这只能通过Apple提供的特殊权利来完成。该权利使您可以调用在问题中引用的CTCellularPlanProvisioning.addPlan(with: ) API

0
投票

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

步骤1

使用您的开发者帐户请求eSIM权利Request from here

步骤2

Apple将在一段时间后批准该权利(对我而言,这花费了几个月的时间)您可以从应用程序配置文件设置中检查Apple是否已批准该权利App profile setting (Certificate manager)

步骤3

通过在其中启用eSIM授权来更新Xcode中的开发人员和发行资料。

步骤4

使用以下键和值更新您的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/>

步骤5(可能是可选的)

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

<key>com.apple.CommCenter.fine-grained</key>
<array>
    <string>public-cellular-plan</string>
</array> 

步骤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")
            }
        }
    }
© www.soinside.com 2019 - 2024. All rights reserved.