When working with Hyperloop and native modules, there are situations where you want to be notified about application-level events, like:
- Finish launching
- Push notifications (background and foreground)
- Background tasks
- URL-handlers / Deep linking
- Shortcut item interaction
- User activity handling
Titanium exposes events to the SDK for all of these, but for module developers (both for Objective-C modules and Hyperloop modules), there have been confusion on how to access them. For example, a module developer would like to use an own provider for handling background push notifications. As part of TIMOB-24266, we generically expose those events ("delegates" in the native world) to developers. In detail, we expose all delegates of the UIApplicationDelegate.
Say you want to configure an API when your application finished booting. The application:didFinishLaunchingWithOptions delegate is made for this. In your native module, you now simply subscribe to the UIApplicationDelegate of the TiApp class, which will then be triggered once the Titanium core receives the delegate message from the iOS core.
_configure selector is available in your module class, e.g. "FacebookModule.m" for Ti.Facebook. Please ensure to also call the super-class to avoid state glitches in your module.
Now that you subscribed to the application delegate, you can use all delegate methods like you would do in a native application. Example for didFinishLaunchingWithOptions:
This will log a simple message with an INFO log-level (remember, there are TRACE, INFO, WARN and ERROR). Here you would configure your native SDK and your module would be ready to go. And this is it! Update your modules today and make use of the new core-technologies. But please note that you need to bump the minimum SDK to 7.1.0 in case you are using this solution. Older SDK's will not crash but ignore the setting because the
registerApplicationDelegate: selector will be nil.
To use the new feature in Hyperloop, subscribe with the registerApplicationDelegate method as well, create the delegate and configure the methods you need. This will likely also be handled internally in the future, so that you only need to require the utility and it does everything else for you.
And that's it! If you have further questions, let us know!