ios - (eSIM 集成 iOS)如何使用受限 API "addPlan"在 iOS 设备中启用 e-sim 配置文件

标签 ios swift entitlements cellular-network core-telephony

到处搜索后我发现有一种方法可以使用以下 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)
}

I am using CoreTelephony framework

我们会提供任何帮助

查看其他应用后,我发现 GigSky 也在做同样的事情,有人知道他们在做什么吗?

更新:

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

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

我请求了,但 apple 没有响应。

最佳答案

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

第一步

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

第 2 步

苹果会在一段时间后批准授权(对我来说花了几个月) 您可以检查 Apple 是否已从您的应用配置文件设置中批准该权利 App profile setting (Certificate manager)

第 3 步

下载 App Dev and Distribution 配置文件(通过选择 eSIM 授权作为步骤 #2)。

第四步

使用以下键和值更新您的 info.plist

<key>CarrierDescriptors</key>

<array>
     <dict>
     <key>MCC</key> //Mobile country code
         <string>’mnc value’</string>
     <key>MNC</key> // Mobile network code
         <string>’mnc value’</string>
     </dict>
</array>
<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")
            }
        }
    }

关于ios - (eSIM 集成 iOS)如何使用受限 API "addPlan"在 iOS 设备中启用 e-sim 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53605419/

相关文章:

swift - 传递给泛型函数时如何访问@Published 属性的包装值

java - Java 程序的 wso2 权利

ios - 退出应用商店导出带有开发证书的 IPA

macos - macOS 应用程序组名称应该以 `group.` 还是开发团队 ID 开头?

ios - 在 SWIFT 中的函数链中间等待闭包完成

ios - 将中间带有空终止字符的 C unsigned char 数组转换为 Objective-C NSString

json - 尝试将 json 解析为类对象失败

arrays - 将简单代码集成到复杂代码中

ios - Google Admob 集成错误

ios - 添加到 UITableView 时在 Storyboard 中使用 UITableViewCells 的正确方法是什么