如何以编程方式获取电话(iOS)提供商列表?

时间:2018-08-22 04:39:40

标签: ios swift core-telephony

是否可以在电话上访问提供商列表?

我已经找到了房屋供应商。但是尚不清楚如何看待其他提供商。

struct InfoProvider {
    let networkOperator: String
    let country: String?
    let mobileCountryCode: String?
    let mobileNetworkCode: String?
}

func getHomeProvider() -> InfoProvider? {
    var homeProvider: InfoProvider? = nil
    let networkInfo = CTTelephonyNetworkInfo()
    if let carrier = networkInfo.subscriberCellularProvider {
        if let carrierName = carrier.carrierName {
            homeProvider = InfoProvider(networkOperator: carrierName,
                                      country: carrier.isoCountryCode,
                                      mobileCountryCode: carrier.mobileCountryCode,
                                      mobileNetworkCode: carrier.mobileNetworkCode)
        }
    }
    return homeProvider
}

func getProviders() -> [InfoProvider] {
    var providers = [InfoProvider]()
    // home provider record
    if let homeProvider = self.getHomeProvider() {
        providers.append(homeProvider)
    }
    /*
     recording of other providers
    */
    return providers
}

0 个答案:

没有答案