I have done something like
CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
networkInfo.subscriberCellularProviderDidUpdateNotifier = ^ (CTCarrier * carrier)
{Do some stuff here
};
to get the notification when the cell service provider changes and do some tasks.The documentation says:
A block object that is dispatched on
the default priority global dispatch
queue 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.To handle changes in cellular service
provider information, define a block
in your application and assign it to
this property. The block must be
implemented to support being called
from any context.
I am not sure where to implement this in my code and will it exceute if my application is running in background or suspended.
This block gets executed if the application is running and the carrier changes.So if we want to do some stuff when the carrier changes it can be done here.i have tested it and this works.