Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

We have a product where the user registers by providing their phone number.

However after they register they could potentially change their sim.

Is it possible to programatically determine if the sim has been removed or inserted?

(Thanks if you provide it, but any digression comments on the use of using the phone number in the first place would be irrelevant to this discussion, I don't want to discuss that aspect of things, only the sim aspect).

like image 560
Gruntcakes Avatar asked Jun 03 '12 16:06

Gruntcakes


1 Answers

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).

like image 97
Oleg Trakhman Avatar answered Sep 28 '22 04:09

Oleg Trakhman