Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
CTIndicators - iPhone Development Wiki


From iPhone Development Wiki

CTIndicators is an API in CoreTelephony.framework that can be used to get the signal strength, voicemail status, etc.

Getting the cellular signal strength

The code below can be used to get the raw strength, graded strength as well as the number of bars (as seen in the status bar).

#include <CoreFoundation/CoreFoundation.h>
#include <CoreTelephony/CoreTelephony.h>

static void SignalStrengthDidChange(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
	long int raw = 0;
	long int graded = 0;
	long int bars = 0;

	CTIndicatorsGetSignalStrength(&raw, &graded, &bars);

	printf("Signal strength changed! Raw: %li, graded: %li bars: %li\n", raw, graded, bars);
	// Prints something like:
	// Signal strength changed! Raw: -96, graded: 27 bars: 3

int main(int argc, char *argv[])
	// Register as a listener to the kCTIndicatorsSignalStrengthNotification notification to be notified when the signal strength changed.
	CTTelephonyCenterAddObserver(CTTelephonyCenterGetDefault(), NULL, SignalStrengthDidChange, kCTIndicatorsSignalStrengthNotification, NULL, CFNotificationSuspensionBehaviorCoalesce);

	// Get the initial strength.


	return 0;

External links