views:

789

answers:

1

I would like to my object to receive notification with the DeviceToken becomes available. Is there a way to delegate only certain functions from the UIApplication to my class?

Update:

I'm not so much interested in accessing it from the application delegate, I already have an application delegate, but want to respond to the event via call back or some observer method if it's possible.

+1  A: 

Despite not being marked as such in the documentation, all UIApplicationDelegate methods are optional, so you can simply implement the ones you require, and ignore the ones you don't.

However, you'll probably want to implement all three of the APS methods, rather than just the one indicating registration success!

hatfinch
I'm sorry my question might not be that clear. I already have an application delegate, but I want some code running in one of my controllers or else where to be able to respond to or listen for the event.
Steve918
Create a "APSDelegate" protocol containing exact copies of the 3 APS UIApplicationDelegate method prototypes.In your application delegate, create a "apsDelegate" property of type id<APSDelegate>. Implement the three APS methods like this:- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{ [self.apsDelegate application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];}(same pattern for the other two).Now your controller can simply register with your application delegate. Bob's your uncle!
hatfinch