Search code examples
iosapple-push-notificationsurbanairship.com

How does Urban Airship gets a push token without implementing application:didRegisterForRemoteNotificationsWithDeviceToken:


I've implemented Urban Airship's SDK for iOS8 and above.

Everything is OK, and I'm able to send push messages to my device.

I have noticed that i wasn't required to implement the following method:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{

}

which is typically used to pass the token from apple to a remote server.

How is this possible?

Thanks.


Solution

  • Figured it out.

    All you need to do is to create a class that inherits from UIResponder, and the conforms to UIApplicationDelegate protocol.

    At run time, you will need to:

    [[UIApplication sharedApplication] setDelegate:someNewDelegate];
    

    and to foreword the calls to the old delegate (so keep a pointer to it).

    ** EDIT **

    There is also the option of Swizzling. have a look: http://nshipster.com/method-swizzling/