此API是apple私有API,所以只可运用在越狱设备中,如果提交appstore,会遭遇apple的拒绝上架反馈!
#import <dlfcn.h> int getSignalLevel()
{
void *libHandle = dlopen("/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony",RTLD_LAZY);//获取库句柄
int (*CTGetSignalStrength)(); //定义一个与将要获取的函数匹配的函数指针
CTGetSignalStrength = (int(*)())dlsym(libHandle,"CTGetSignalStrength"); //获取指定名称的函数 if(CTGetSignalStrength == NULL)
return -;
else{
int level = CTGetSignalStrength();
dlclose(libHandle); //切记关闭库
return level;
}
}