camelCase
camelCase

Reputation: 27

Trapping general UI activity within an iPhone app

I am developing an iPhone app that polls an internet web service. The poll rate will decay from once every 20 seconds to once every 15 minutes if the iPhone is sitting idle in a dock running my application. If the user taps the screen or begins moving around the UI I need to revive the polling rate back up to 20 seconds.

Is there a universal top level event handler where I can trap any user activity?

If not I propose to capture user activity at 4 major feature usage points such as any push and pop activity in my productivity app's nav controller bar.

Upvotes: 0

Views: 136

Answers (1)

Vladimir
Vladimir

Reputation: 170859

Try to implement -applicationDidBecomeActive and -applicationWillResignActive in your application delegate.
To handle all user activity you can also implement your custom UIWindow subclass and override -(void)sendEvent:(UIEvent*)event method there:

- (void)sendEvent:(UIEvent*)event {
   [super sendEvent:event];
   ... 
}

Edit: You may also listen to UIDeviceBatteryStateDidChangeNotification (available from SDK 3.0) to get notified when device is plugged/unplugged into power

Upvotes: 1

Related Questions