DSRawat
DSRawat

Reputation: 107

Access the list of SIM mobile numbers installed in the iPhone

Can I get list of all sim installed in my iPhone including eSim and get its number ?

I have requirement in which I need at the time of registration , at user mobile number, user installed sim numbers list shows for dropdown.

Any way to solve it? Is apple allowed it ? If yes please suggest code at swift language. I tried to detect SIM but not getting sim phone number list.

import UIKit
import CoreTelephony

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        listSIMCardDetails()
    }
    
    func listSIMCardDetails() {
        let networkInfo = CTTelephonyNetworkInfo()
        if let subscriber = networkInfo.subscriberCellularProvider {
            print("Carrier Name: \(subscriber.carrierName ?? "Unknown")")
            print("Mobile Country Code (MCC): \(subscriber.mobileCountryCode ?? "Unknown")")
            print("Mobile Network Code (MNC): \(subscriber.mobileNetworkCode ?? "Unknown")")
            print("ISO Country Code: \(subscriber.isoCountryCode ?? "Unknown")")
            print("Allows VOIP: \(subscriber.allowsVOIP)")
        } else {
            print("No SIM Card Detected")
        }
    }
}

Upvotes: 1

Views: 252

Answers (1)

Shahid Afridi
Shahid Afridi

Reputation: 11

Use this property to allow you some suggestion of your contact number textfield.textContentType = "telephoneNumber"

Upvotes: 1

Related Questions