How to Determine If the Sim/Phone Number Has Changed

Is it possible to determine if the SIM/Phone number has changed?

Yes, of course it is possible. Link CoreTelephony.framework to make following code compile:

CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = info.subscriberCellularProvider;
NSString *mobileCountryCode = carrier.mobileCountryCode;
NSString *carrierName = carrier.carrierName;
NSString *isoCountryCode = carrier.isoCountryCode;
NSString *mobileNetworkCode = carrier.mobileNetworkCode;

// Try this to track CTCarrier changes
info.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier* inCTCarrier) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"User did change SIM");
});
};

By values of mobileCountryCode, mobileNetworkCode, carrierName, isoCountryCode you can judge about presence of SIM. (Without SIM they become incorrect).

There is also some undocumented functions/notifications in CoreTelephony, but your app may be banned by Apple if you'll use them. Anyway:

// Evaluates to @"kCTSIMSupportSIMStatusReady" when SIM is present amd ready; 
// there are some other values like @"kCTSIMSupportSIMStatusNotInserted"
NSString* CTSIMSupportGetSIMStatus();

// Use @"kCTSIMSupportSIMStatusChangeNotification" to track changes of SIM status:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(SIMNotification:)
name:@"kCTSIMSupportSIMStatusChangeNotification"
object:nil
];

// This one copies current phone number
NSString* CTSettingCopyMyPhoneNumber()

Addendum Another possible (and legal) solution: if your company has a database of phone numbers, you can send an sms or call(and cut) any specific number to verify that user still uses the same phone number.

UPDATE Function NSString* CTSettingCopyMyPhoneNumber() doesn't work anymore (returns empty string).

How to determine if phone number has changed?

Update 2

One (not the best) way it's detecting carrier changing. Here you can see how to get carrier's name. Save it at first launch and do compare on next launches.

Update 3

I'd recommend to you look at Core Telephony Network reference and especially at CTTelephonyNetworkInfo reference

subscriberCellularProviderDidUpdateNotifier allow you respond on events such like:

... when the user’s cellular provider information changes. This occurs, for example, if a user
swaps the device’s SIM card with one
from another provider, while your
application is running

how to find simcard is change or not in android device?

there is one suggestion :-

On your application launch (first time) save/store Unique number of SIM(Subscriber ID).

on every phone bootup again fetch this unique number of SIM(Subscriber ID). and match with what you have stored in your app. if matched it is ok, else sim is changed.
below is the method you needed to get SubscriberID number.

IMSI = m_telephonyManager.getSubscriberId();

How to identify when SIM changed in iPhone?

You are able to sign up for a notification using subscriberCellularProviderDidUpdateNotifier in
CTTelephonyNetworkInfo

However you will only be notified if the swap occurs while your app is running. You will still be unable to detect if the user changes the SIM to another SIM from the same operator when your app is not running.



Related Topics



Leave a reply



Submit