我到处都可以找到相同的解决方案来检索承运人信息。因此,我确定它可以正常工作。但是,对我来说,它返回一个错误:
2018-08-08 14:24:55.100318-0400 ReportSpam1Extension[4192:295308]
[NetworkInfo] Descriptors query returned error: Error
Domain=NSCocoaErrorDomain Code=4099 "The connection to service named
com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo=
{NSDebugDescription=The connection to service named
com.apple.commcenter.coretelephony.xpc was invalidated.
产生此错误的代码在消息扩展名之内:
let networkInfo = CTTelephonyNetworkInfo()
let carrier = networkInfo.subscriberCellularProvider
print(carrier)
我也链接了二进制文件。我不确定我在这里缺少什么
更新:它在父应用程序中有效,但在扩展程序中无效! 我使用的扩展名是(不需要的通信扩展名)