From iPhone Development Wiki
Revision as of 13:34, 28 October 2014 by Uroboro (talk | contribs) (Polish)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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