CoreTelephony eSIM functions not working on device
So... after a lot of trial an error I was able to solve this little issue.
There are 2 things to know about supportsCellularPlan()
(other then having the eSIM entitlements of course).
First:
You need to have WiFi enabled for it to work as it seems to need to connect with Apple for some checks.
Second:
It requires the CarrierDescriptors
to be entered correctly in your info.plist
as it is carrier-bound.
Once you have that, it should work as expected.
(eSIM Integration iOS) How to use restricted API addPlan to enable e-sim profile in iOS device
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>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/>
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()
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")
}
}
}
Core telephony CTCarrier and isoCountryCode. How to get user's current cellular provider's country?
As the documentation explains:
Note
In this context, the “home” provider is the one with which the user has a cellular plan, as opposed to a roaming provider.
So, you will always get FR, even when roaming, if your home provider is in France.
The reason there are two possible values is that iPhones now support up to two sims; One physical and one e-SIM, so there may be two different cellular providers on a phone.
Related Topics
Video with Gpuimagechromakeyfilter Has Tint When Played in Transparent Gpuimageview
Didoutputsamplebuffer Delegate Not Called
Calculate New Coordinates with Starting Position and Distance
Sorting Struct Array in Swift 4
Change Duration (Speed) on a Running Animation
How to Rotate Custom Userlocationannotationview Image Using Mapkit in Swift
Get Section Number in Custom Cell Button Action
Allow Users to Send Messages to Multiple Users Simultaneously in a Messaging App
Change Splash Screen Image Programmatically
Modeling Sub-Collections in Mongodb Realm Sync
Turn Swift Object into a JSON String