问题
There is this link however it leaves out the iOS 12+ Objective C method. Here's what I have attempted:
Added to the application delegate:
@property (strong, nonatomic) CTTelephonyNetworkInfo *telephonyInfo;
Then in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
self.telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
self.telephonyInfo.serviceSubscriberCellularProvidersDidUpdateNotifier = ^(NSString *entry) {
dispatch_async(dispatch_get_main_queue(), ^{
qDebug() << "User did change SIM" << entry;
});
};
...
}
But the code never gets executed (by breakpoint or log message) when I remove the SIM. How can i get the notifications in Obj-C in iOS 12+?
来源:https://stackoverflow.com/questions/60869036/objective-c-version-of-servicesubscribercellularprovidersdidupdatenotifier-for-i