I am developing a non-appstore app for iOS. I want to read the cellular signal strength in my code.
I know Apple doesn't provide any API by which we can achieve this.
Is there any private API that can be used to achieve this? I have gone through the various threads regarding this issue but could not find any relevant info.
It is completely possible because there is an app in the app-store for detecting the carrier's signal strength.
Get signalStreght IOS9:
I haven't tested it, but apparently this is now a method of
CTTelephonyNetworkInfo
instead of a global/static function.The return type is
id
, so I think you get either aNSDictionary
(as the_cachedSignalStrength
ivar implies) or anNSNumber
(as the old function implies).This changed in iOS 8.3, as you can see from the commit.
Note that this is still not documented! So if your app will go in the App Store, take your precautions.
It is not very hard.
Code:
And you are done.
Update May 2016
Apple removed this opportunity.
I briefly looked at the VAFieldTest project located at Github.
There seems to be
getSignalStrength()
andregister_notification()
functions in Classes/VAFieldTestViewController.m that might be interesting to you as they call intoCoreTelephony.framework
.I am pretty confident that some of the used calls are undocumented in the CoreTelephony framework documentation from Apple and therefore private - any app in the AppStore must have slipped passed inspection.
To get signal streght in iOS 9 or above in Swift 3, without using the private API from CoreTelephony -
CTGetSignalStrength()
. Just scouring the statusBar view.Attention: If the status bar is hidden, the key "statusBar" will return nil.
Here's Lucas' answer converted to Xamarin, and tested on iOS 10.2.1: