简体   繁体   English

iOS中的SIM卡更改检测

[英]Sim card change detection in iOS

Somebody please help with the code for sim card detection change in iOS on Swift. 有人请协助Swift上的iOS中的SIM卡检测更改代码。

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. 我们有一个可以让用户通过电话号码进行身份验证的应用程序,并且我们想检测用户何时更改其sim卡(如果应用程序在后台)并显示警报,询问他是否要使用新号码进行身份验证。 Basically we want to detect the carrier change of the phone. 基本上,我们要检测电话的运营商变更。

In my Appdelegate (DidFinishLaunching method):- 在我的Appdelegate(DidFinishLaunching方法)中:-

    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. 这没有检测到SIM卡更改。 What am I doing wrong? 我究竟做错了什么? Please guide. 请指导。

Thanks In Advance, 提前致谢,

In app terminate: check APNS devicetoken. 在应用终止中:检查APNS设备令牌。 If simcard changes then devicetoken changes too. 如果simcard更改,那么devicetoken也将更改。 Check with before devicetoken. 在设备令牌之前进行检查。 When as app is running: Use CTTelephonyNetworkInfo().subscriberCellularProviderDidUpdateNotifier . 当应用程序运行时:使用CTTelephonyNetworkInfo().subscriberCellularProviderDidUpdateNotifier

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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