ios - iOS12+的Objective-C版serviceSubscriberCellularProvidersDidUpdateNotifier?
问题描述
有这个链接,但是它忽略了 iOS 12+ Objective C 方法。这是我尝试过的:
添加到应用程序委托:
@property (strong, nonatomic) CTTelephonyNetworkInfo *telephonyInfo;
然后在
- (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;
});
};
...
}
但是当我移除 SIM 卡时,代码永远不会被执行(通过断点或日志消息)。如何在 iOS 12+ 的 Obj-C 中获取通知?
解决方案
推荐阅读
- java - 有什么方法可以将子项目 buildSrc 包含到根项目的 buildSrc 类路径中?
- php - 基于关键字搜索从 eBay API 中检索 WatchCount
- python - 如何从 UCI 机器学习存储库中导入 .data 和 .lisp 文件?
- html - 从 netlify 托管静态站点两次加载我的脚本和样式
- reactjs - 如何直接在当前文件夹中创建 React 应用
- oracle11g - 优化器不使用索引
- javascript - 返回值数组Javascript的数组的属性
- php - 无法创建 php 注册表单
- r - roxygen2 中方法的命名空间
- php - Wmcs 客户端自定义字段值