Search code examples
iosuiapplicationdelegateurbanairship.comuiapplication

Bypass UABaseAppDelegateSurrogate for my custom UIApplicationDelegate


In my iOS app, I would like to retrieve a reference to my app delegate using [[UIApplication sharedApplication] delegate], however this is returning an instance of class UABaseAppDelegateSurrogate instead of my custom UIApplicationDelegate class.

I understand that this surrogate is somehow used for receiving notifications, but do I need this? My app delegate implements all necessary methods for receiving notifications, and I would like to bypass this surrogate class so I can call methods on my custom app delegate. I don't know when this started happening, but I used to get my custom app delegate from [[UIApplication sharedApplication] delegate].


Solution

  • From the Urban Airship docs:

    The Urban Airship library will automatically integrate with your app, so you do not need to implement any of the push-related UIApplicationDelegate protocol methods or pass notifications to the library. The library is able to do this by setting itself as the app delegate, intercepting messages and forwarding them to your original app delegate. If you would like to disable this behavior and implement the delegate callbacks in your own delegate, you can set automaticSetupEnabled to NO in either your AirshipConfig.plist file or on a UAConfig object passed to [UAirship takeOff:(UAConfig *)config];