I monitored both the standard Darwin notifications and the Core Telphony notifications on a jailbroken iOS 5 iPhone.
I did not see any notifications that really do what you want.
There are a few Core Telephony notifications that come out, but not on every transmit start and end. It looks like when the data service connects, there might be some notifications, but again, they really aren't exactly what you asked for:
kCTIndicatorRadioTransmitNotification
kCTRegistrationDataStatusChangedNotification
If you want to try monitoring all the Core Telephony notifications for yourself, you can use the Core Telephony framework, and the CT notification center:
-(void) registerCallback {
id ct = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver(ct, // center
NULL, // observer
telephonyEventCallback, // callback
NULL, // event name (or all)
NULL, // object
CFNotificationSuspensionBehaviorDeliverImmediately);
}
static void telephonyEventCallback(CFNotificationCenterRef center, void* observer, CFStringRef name, const void* object, CFDictionaryRef userInfo)
{
//NSLog(@"telephonyEventCallback()");
NSString* notifyName = (__bridge NSString*)name;
if ([notifyName isEqualToString:@"kCTMessageReceivedNotification"]) { // received SMS
} /* look for other notification names here */
}
In the above call, I pass NULL
to the CTTelephonyCenterAddObserver()
call, which registers for all notifications. You can of course pass the name of one particular notification if you know what you're looking for, like the example you posted for com.apple.iokit.hid.displayStatus
.
Regarding john.k.doe's option, you might try using Key Value Observing on that property, to get notified when it changes:
UIApplication* app = [UIApplication sharedApplication];
[app addObserver: self forKeyPath: @"networkActivityIndicatorVisible" options: NSKeyValueObservingOptionNew context: nil];
where your observer callback is:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"networkActivityIndicatorVisible"]) {
// process here
NSLog(@"network activity indicator change!");
BOOL active = [UIApplication sharedApplication].networkActivityIndicatorVisible;
}
}
I'm not sure if KVO will still work in the background, and it might depend on how your app manages being backgrounded.
But, of course, that requires apps to actually use that property when they access the network, which not all of them do. It's unfortunate that Apple even made that indicator something that 3rd-party developers need to control. On Android and BlackBerry, the OS is smart enough to know when it's transmitting/receiving.
So, this is still only partly what you need :(