public class

UAirship

extends Object
java.lang.Object
   ↳ com.urbanairship.UAirship

Class Overview

UAirship manages the shared state for all Urban Airship services. UAirship.takeOff() should be called to initialize the class on Application.onCreate().

Summary

Nested Classes
interface UAirship.OnReadyCallback Callback interface used to notify app when UAirship is ready. 
@interface UAirship.Platform  
Constants
String ACTION_AIRSHIP_READY Broadcast that is sent when UAirship is finished taking off.
int AMAZON_PLATFORM Amazon platform type.
int ANDROID_PLATFORM Android platform type.
Fields
public static boolean LOG_TAKE_OFF_STACKTRACE Flag to enable printing take off's stacktrace.
Public Methods
ActionRegistry getActionRegistry()
The default Action Registry.
AirshipConfigOptions getAirshipConfigOptions()
Returns the current configuration options.
Analytics getAnalytics()
Returns the UAirship Analytics instance.
static int getAppIcon()
Returns the drawable ID for the current Application's icon.
static ApplicationInfo getAppInfo()
Returns the current Application's ApplicationInfo.
static String getAppName()
Returns the current Application's name.
static Context getApplicationContext()
Returns the current Application's context.
ApplicationMetrics getApplicationMetrics()
Returns the ApplicationMetrics instance.
Automation getAutomation()
Returns the Automation instance.
ChannelCapture getChannelCapture()
Returns the ChannelCapture instance.
InAppMessageManager getInAppMessageManager()
Returns the InAppMessageManager instance.
RichPushInbox getInbox()
Returns the RichPushInbox instance.
UALocationManager getLocationManager()
Returns the UALocationManager instance.
MessageCenter getMessageCenter()
The default Message Center.
NamedUser getNamedUser()
Returns the NamedUser instance.
static PackageInfo getPackageInfo()
Returns the Application's PackageInfo
static PackageManager getPackageManager()
Returns the Application's package manager.
static String getPackageName()
Returns the Application's package name.
int getPlatformType()
Returns the platform type.
PushManager getPushManager()
Returns the PushManager instance.
static String getUrbanAirshipPermission()
Returns the permission for sending Urban Airship push and registration broadcasts.
static String getVersion()
Returns the current Urban Airship version.
Whitelist getWhitelist()
The URL whiteList used to determine when to inject the Urban Airship Javascript Interface.
static boolean isFlying()
Tests if UAirship has been initialized and is ready for use.
static boolean isMainProcess()
Tests if the current process is the main process.
static boolean isTakingOff()
Tests if UAirship is currently taking off.
static void land()
Cleans up and closes any connections or other resources.
static UAirship shared()
Returns the shared UAirship singleton instance.
static Cancelable shared(UAirship.OnReadyCallback callback)
Requests the airship instance asynchronously.
static Cancelable shared(UAirship.OnReadyCallback callback, Looper looper)
Requests the airship instance asynchronously.
static void takeOff(Application application)
Take off with config loaded from the airshipconfig.properties file in the assets directory.
static void takeOff(Application application, UAirship.OnReadyCallback readyCallback)
Take off with a callback to perform airship configuration after takeoff.
static void takeOff(Application application, AirshipConfigOptions options)
Take off with defined AirshipConfigOptions.
static void takeOff(Application application, AirshipConfigOptions options, UAirship.OnReadyCallback readyCallback)
Take off with a callback to perform airship configuration after takeoff.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_AIRSHIP_READY

Broadcast that is sent when UAirship is finished taking off.

Constant Value: "com.urbanairship.AIRSHIP_READY"

public static final int AMAZON_PLATFORM

Amazon platform type. Only ADM transport will be allowed.

Constant Value: 1 (0x00000001)

public static final int ANDROID_PLATFORM

Android platform type. Only GCM transport will be allowed.

Constant Value: 2 (0x00000002)

Fields

public static boolean LOG_TAKE_OFF_STACKTRACE

Flag to enable printing take off's stacktrace. Useful when debugging exceptions related to take off not being called first.

Public Methods

public ActionRegistry getActionRegistry ()

The default Action Registry.

public AirshipConfigOptions getAirshipConfigOptions ()

Returns the current configuration options.

Returns
  • The current configuration options.

public Analytics getAnalytics ()

Returns the UAirship Analytics instance.

Returns

public static int getAppIcon ()

Returns the drawable ID for the current Application's icon.

Returns
  • The drawable ID for the application's icon, or -1 if the ID cannot be found.
Throws
IllegalStateException if takeOff has not been called.

public static ApplicationInfo getAppInfo ()

Returns the current Application's ApplicationInfo. Wraps PackageManager's getApplicationInfo() method.

Returns
  • The shared ApplicationInfo object for this application.
Throws
IllegalStateException if takeOff has not been called.

public static String getAppName ()

Returns the current Application's name. Wraps PackageManager's getApplicationLabel() method.

Returns
  • The current Application's name
Throws
IllegalStateException if takeOff has not been called.

public static Context getApplicationContext ()

Returns the current Application's context.

Returns
  • The current application Context.
Throws
IllegalStateException if takeOff has not been called.

public ApplicationMetrics getApplicationMetrics ()

Returns the ApplicationMetrics instance.

Returns

public Automation getAutomation ()

Returns the Automation instance.

Returns

public ChannelCapture getChannelCapture ()

Returns the ChannelCapture instance.

Returns

public InAppMessageManager getInAppMessageManager ()

Returns the InAppMessageManager instance.

Returns

public RichPushInbox getInbox ()

Returns the RichPushInbox instance.

Returns

public UALocationManager getLocationManager ()

Returns the UALocationManager instance.

Returns

public MessageCenter getMessageCenter ()

The default Message Center.

Returns
  • The default message center.

public NamedUser getNamedUser ()

Returns the NamedUser instance.

Returns

public static PackageInfo getPackageInfo ()

Returns the Application's PackageInfo

Returns
  • The PackageInfo for this Application
Throws
IllegalStateException if takeOff has not been called.

public static PackageManager getPackageManager ()

Returns the Application's package manager.

Returns
  • The package manager.
Throws
IllegalStateException if takeOff has not been called.

public static String getPackageName ()

Returns the Application's package name.

Returns
  • The package name.
Throws
IllegalStateException if takeOff has not been called.

public int getPlatformType ()

Returns the platform type.

Returns

public PushManager getPushManager ()

Returns the PushManager instance.

Returns

public static String getUrbanAirshipPermission ()

Returns the permission for sending Urban Airship push and registration broadcasts.

Returns
  • The Urban Airship broadcast permission.
Throws
IllegalStateException if takeOff has not been called.

public static String getVersion ()

Returns the current Urban Airship version.

Returns
  • The Urban Airship version number.

public Whitelist getWhitelist ()

The URL whiteList used to determine when to inject the Urban Airship Javascript Interface.

Returns
  • The url whitelist.

public static boolean isFlying ()

Tests if UAirship has been initialized and is ready for use.

Returns
  • true if UAirship is ready for use; false otherwise

public static boolean isMainProcess ()

Tests if the current process is the main process.

Returns
  • true if currently within the main process; false otherwise.

public static boolean isTakingOff ()

Tests if UAirship is currently taking off.

Returns
  • true if UAirship is taking off; false otherwise

public static void land ()

Cleans up and closes any connections or other resources.

public static UAirship shared ()

Returns the shared UAirship singleton instance. This method will block until airship is ready.

Returns
  • The UAirship singleton.
Throws
IllegalStateException if takeoff is not called prior to this method.

public static Cancelable shared (UAirship.OnReadyCallback callback)

Requests the airship instance asynchronously.

This method calls through to shared(com.urbanairship.UAirship.OnReadyCallback, android.os.Looper) with a null looper.

Parameters
callback An optional callback
Returns
  • A cancelable object that can be used to cancel the callback.

public static Cancelable shared (UAirship.OnReadyCallback callback, Looper looper)

Requests the airship instance asynchronously.

If airship is ready, the callback will not be called immediately, the callback is still dispatched to the specified looper. The blocking shared may unblock before any of the asynchronous callbacks are executed.

Parameters
callback An optional callback
looper A Looper object whose message queue will be used for the callback, or null to make callbacks on the calling thread or main thread if the current thread does not have a looper associated with it.
Returns
  • A cancelable object that can be used to cancel the callback.

public static void takeOff (Application application)

Take off with config loaded from the airshipconfig.properties file in the assets directory. See applyDefaultProperties(Context).

Parameters
application The application (required)

public static void takeOff (Application application, UAirship.OnReadyCallback readyCallback)

Take off with a callback to perform airship configuration after takeoff. The ready callback will be executed before the UAirship instance is returned by any of the shared methods. The config will be loaded from airshipconfig.properties file in the assets directory. See applyDefaultProperties(Context).

Parameters
application The application (required)
readyCallback Optional ready callback. The callback will be triggered on a background thread that performs takeOff.

public static void takeOff (Application application, AirshipConfigOptions options)

Take off with defined AirshipConfigOptions.

Parameters
application The application (required)
options The launch options. If not null, the options passed in here will override the options loaded from the .properties file. This parameter is useful for specifying options at runtime.

public static void takeOff (Application application, AirshipConfigOptions options, UAirship.OnReadyCallback readyCallback)

Take off with a callback to perform airship configuration after takeoff. The ready callback will be executed before the UAirship instance is returned by any of the shared methods.

Parameters
application The application (required)
options The launch options. If not null, the options passed in here will override the options loaded from the .properties file. This parameter is useful for specifying options at runtime.
readyCallback Optional ready callback. The callback will be triggered on a background thread that performs takeOff.