Programmatically getting the iPhone's carrier signal strength

孤人 提交于 2020-01-01 05:14:05

问题


Is there a way to get the iPhone's carrier, and/or the current signal strength, using Objective-C? I know how to determine if a data connection is present, and whether or not that connection is wi-fi vs. cellular. I also know that you can manually place the iPhone into "field test" mode by going to the phone app, and dialing #3001*12345*# and hitting Send.


回答1:


You made me curious and I found out that it's actually *3001#12345#* (hashes and stars exchanged).




回答2:


This probably won't pass Apple's review, but you can use CTTelephony notifications. First, link against CTTelephony. Now just use this:

static void callback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {

    CFShow(name)

    NSString *sName = name;
    if ([sName isEqualToString:@"kCTIndicatorsSignalStrengthNotification"]) {
        if (userInfo) CFShow(userInfo);
    }    
}

And this to subscribe:

id ct = CTTelephonyCenterGetDefault(); 

    CTTelephonyCenterAddObserver(
                                 ct, 
                                 NULL, 
                                 callback,
                                 NULL,
                                 NULL,
                                NULL);


来源:https://stackoverflow.com/questions/1270098/programmatically-getting-the-iphones-carrier-signal-strength

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