15.8 C
London
Thursday, May 16, 2024

swift – Sign power, CID, LAC, and so on.) on iOS for an inner Flutter app


I’m creating an inner cell app in Flutter and have to retrieve detailed mobile community data akin to sign power (dBm), cell ID (CID), location space code (LAC), and extra on iOS. I perceive that iOS restricts entry to a few of this data via public APIs, however since this app is for inner use solely, I’m on the lookout for any attainable answer.

Right here is the Swift code I’m utilizing to get community data:

import Basis
import CoreTelephony

class RfSignalStrengthImpl: RfSignalStrengthApi {
    func getCellularSignalStrength(completion: @escaping (Outcome<CellularSignalStrength, Error>) -> Void) {
        let networkInfo = CTTelephonyNetworkInfo()

        guard let provider = networkInfo.serviceSubscriberCellularProviders?.values.first else {
            completion(.failure(NSError(area: "com.xxxx.yyyy", code: 0, userInfo: [NSLocalizedDescriptionKey: "Carrier not found"])))
            return
        }

        let carrierName = provider.carrierName ?? "Unknown"
        let mobileCountryCode = provider.mobileCountryCode ?? "Unknown"
        let mobileNetworkCode = provider.mobileNetworkCode ?? "Unknown"
        let radioAccessTechnology = networkInfo.serviceCurrentRadioAccessTechnology?.values.first ?? "Unknown"

        var connectionStatus = "Unknown"
        if let radioTech = networkInfo.currentRadioAccessTechnology {
            swap radioTech {
            case CTRadioAccessTechnologyGPRS:
                connectionStatus = "GPRS"
            case CTRadioAccessTechnologyEdge:
                connectionStatus = "EDGE"
            case CTRadioAccessTechnologyCDMA1x:
                connectionStatus = "CDMA1x"
            case CTRadioAccessTechnologyCDMAEVDORev0:
                connectionStatus = "EvDo Rev. 0"
            case CTRadioAccessTechnologyCDMAEVDORevA:
                connectionStatus = "EvDo Rev. A"
            case CTRadioAccessTechnologyHSDPA:
                connectionStatus = "HSDPA"
            case CTRadioAccessTechnologyHSUPA:
                connectionStatus = "HSUPA"
            case CTRadioAccessTechnologyLTE:
                connectionStatus = "LTE"
            default:
                connectionStatus = "Unknown"
            }
        }

        let duplexMode = "Unknown"
        let stage: Int64 = -1
        let dbm: Int64 = -1
        let rssi: Int64 = -1
        let rsrq: Int64 = -1

        let cid: Int64 = -1
        let lac: Int64 = -1

        let response = CellularSignalStrength(
            stage: stage,
            dbm: dbm,
            rssi: rssi,
            rsrq: rsrq,
            cid: cid,
            lac: lac,
            carrierName: carrierName,
            mobileCountryCode: mobileCountryCode,
            mobileNetworkCode: mobileNetworkCode,
            radioAccessTechnology: radioAccessTechnology,
            connectionStatus: connectionStatus,
            duplexMode: duplexMode
        )
        completion(.success(response))
    }
}

Nevertheless, the output I get is:

{
    stage: -1,
    dbm: -1,
    rssi: -1,
    rsrq: -1,
    cid: -1,
    lac: -1,
    carrierName: --,
    mobileCountryCode: 65535,
    mobileNetworkCode: 65535,
    radioAccessTechnology: CTRadioAccessTechnologyLTE,
    connectionStatus: LTE,
    duplexMode: Unknown
}

As you’ll be able to see, most of the fields have placeholder values or incorrect knowledge.

Query:

How can I retrieve detailed mobile community data on iOS for an inner app? Are there any strategies, public or non-public APIs, or workarounds to get this knowledge, contemplating the app is not going to be distributed through the App Retailer?

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here