1

Does the iOS SDK support system services' event handling? I mean, could I have my app listening for external events such as sms reception, battery level of charge...

I was looking for documentation at iOS developers' site, and it looks like the only types of events I can handle are user events when interacting with the UI, events triggered by UI controls, Cocoa events, accelerometer and GPS events: Event Handling Guide for iOS

Are those actually all the events that can be listened in an app, or am I missing some other documentation about system events as the ones I mentioned?

Thanks

Andr Devs
  • 215
  • 5
  • 14
  • You might want to check out the NSNotificationCenter. Check out this SO post: http://stackoverflow.com/questions/2191594/how-to-send-and-receive-message-through-nsnotificationcenter-in-objective-c – 5StringRyan Nov 04 '12 at 18:37

1 Answers1

1

Checkout NSNotificationCenter.

For battery level change look at UIDeviceBatteryLevelDidChangeNotification defined in UIDevice - you can do:

// Register for battery level and state change notifications.
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(batteryLevelDidChange:)
                                             name:UIDeviceBatteryLevelDidChangeNotification object:nil];

Here's an apple sample:

http://developer.apple.com/library/ios/#samplecode/BatteryStatus/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008812-Intro-DontLinkElementID_2

Not sure about SMS events - found mentions of it not being available via public APIs but that may have changed. Not aware of anything.

bryanmac
  • 37,512
  • 9
  • 85
  • 95