简体   繁体   中英

Sim card change detection in iOS

Somebody please help with the code for sim card detection change in iOS on Swift.

We have an app that lets users authenticate with phone number and we want to detect when user changes his sim(if app is in background) and show alert asking if he wants to authenticate with new number. Basically we want to detect the carrier change of the phone.

In my Appdelegate (DidFinishLaunching method):-

    let info = CTTelephonyNetworkInfo()
    if let cellularProvider  = CTTelephonyNetworkInfo().subscriberCellularProviderDidUpdateNotifier {
        dispatch_async(dispatch_get_main_queue(), { () -> Void in
            print("Notify sim change")

        })
    }

This is not detecting sim card change. What am I doing wrong? Please guide.

Thanks In Advance,

In app terminate: check APNS devicetoken. If simcard changes then devicetoken changes too. Check with before devicetoken. When as app is running: Use CTTelephonyNetworkInfo().subscriberCellularProviderDidUpdateNotifier .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM