(eSIM Integration iOS) How to use restricted API “addPlan” to enable e-sim profile in iOS device

余生颓废 提交于 2020-05-24 20:08:27

问题


After searching everywhere I found there is a way to add eSIM in iPhone using the following API

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

I don't know why but completion handler not returning the result of CTCellularPlanProvisioningAddPlanResult just printing the following error.

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.

I want to know how this API works, You can see my code below

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

Any help would be appricated

After checking other apps I found that GigSky is doing the same, anyone knows how they are doing?

UPDATE:

As of now I found the entitlement request URL check below

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

I requested but apple is not responding.


回答1:


This API is only available for carriers. You need a special entitlement from Apple to be able to call it in your application, otherwise you will get the error you mentioned.

Just to clarify something about eSIMs; there are several ways to add eSIM to the device:

  • the simplest way that most carriers are implementing now is through scanning a QR code from the device settings, which does not require any development work on the carrier's app.
  • The other way is to install the eSIM profile using the carrier app, which can only be done with a special entitlement that is provided by Apple. The entitlement allows you to call CTCellularPlanProvisioning.addPlan(with: ) API that you referred to you in your question



回答2:


With this process, you can integrate eSIM functionality into your iOS app.

Step 1

Request for eSIM entitlement using your developer account Request from here

Step 2

Apple will approve the entitlement after some time (For me it took months) You can check if Apple has approved the entitlement from your app profile setting

Step 3

Download the App Dev and Distribution profile (By selecting eSIM entitlement as Step #2).

Step 4

Update your info.plist with below keys and value

<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/>

Step 5 (Could be optional)

Update your {appname}.entitlements with below key and value

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

Step 6 Code to Add eSIM profile

 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")
            }
        }
    }


来源:https://stackoverflow.com/questions/53605419/esim-integration-ios-how-to-use-restricted-api-addplan-to-enable-e-sim-profi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!