Skip to end of metadata
Go to start of metadata

Icon

This document describes technologies available in Hyperloop 3.1.0+ and Titanium 7.3.0+.

 

When developing iOS modules with Hyperloop, there are situations where you want to present a new view controller from your current context or pass your current context to a new view controller. Natively, you would usually reference "self" as its represents your current UIViewController subclass. In Titanium, your "self" is usually a Ti.UI.Window instance, which is fine for Titanium development, but cannot be used in native development.

That's why Hyperloop includes a number of utility methods that solve these kind of problems. They are exposed in the "TiApp" class that can be required as the following:

indes.js

And that's basically it. As the TiApp class is a singleton in Titanium, the instance methods are done on the TiApp.app() singleton and the class methods on TiApp directly. See the following table for a reference of the available utilities:

Class Methods

Call these methods on the TiApp property directly.

NameParametersReturnDescription
app()voidTiApp The singleton object to call all other API's on.
getController()voidUIViewControllerReturns the application's root view controller.
getTiAppProperties()voidNSDictionaryReturn a read-only dictionary from tiapp.xml properties.

Instance Methods

Call these methods on the TiApp.app() singleton.

NameParametersReturnDescription
showModalController(controller, animated)UIViewController, BOOLvoidPresents a view controller on the top presented view controller (e.g. "presentViewController:animated:").
hideModalController(controller, animated)UIViewController, BOOLvoidHides a currently presented view controller (e.g. "dismissViewControllerAnimated:completion:").
showModalError(error)NSStringvoidShows the "red screen of death" indicating an unhandled error.
startNetwork()voidvoid

Tells application to show network activity indicator.

stopNetwork()voidvoid

Tells application to hide network activity indicator.

registerApplicationDelegate(delegate)

id<UIApplicationDelegate>voidRegisters a new UIApplicationDelegate to the host application.

unregisterApplicationDelegate(delegate)

id<UIApplicationDelegate>voidUnregisters an existing UIApplicationDelegate from the host application.
windowIsKeyWindow()voidBOOLIndicates weather the current window is the key-window of the host application.
getRemoteDeviceUUID()voidNSStringReturns the remote UUID for the current running device.
getSessionId()voidNSStringReturns the unique identifier for the current application launch.
getLaunchOptions()voidNSDictionaryReturns the application's launch options.

Instance Properties

Call these properties on the TiApp.app() singleton.

NameTypeDescription
userAgentNSStringThe user agent string to use for system network requests.
windowUIWindowThe application's primary window.
remoteNotificationNSDictionaryThe details for the last remote notification.
localNotificationNSDictionaryThe details for the last local notification.
userAgentNSStringThe user agent string to use for network requests.

Examples

Present a view controller

This example shows how to open a new view controller in your current application context.

Pass the current view controller

This example shows how to pass your top presented controller to a native method (e.g. in the Facebook SDK).

Get the device's push notifications UUID

 This examples shows how to receive the device's UUID used for remote notifications.

Subscribe to the UIApplicationDelegate

This example shows how to subscribe to the UIApplicationDelegate in order to use the application:didFinishLaunchingWithOptions: delegate method. For more infos, see iOS Modules - Use Native UI Application Delegates in Hyperloop and Native Modules.

Icon

Note: Many native SDK's recommend to initialize them in this delegate. In the Titanium world, you can also do this in the open event of your initial window, which effectively does the same and is more cross-platform fashioned way of implementing this. 

  • No labels