Objective-C version of serviceSubscriberCellularProvidersDidUpdateNotifier for iOS12+?

。_饼干妹妹 提交于 2020-04-16 04:21:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!