public class

UAirship

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

Class Overview

UAirship manages the shared state for all Airship services. UAirship.takeOff() should be called to initialize the class during Application.onCreate() or by using Autopilot.

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.
String EXTRA_AIRSHIP_DEEP_LINK_SCHEME
String EXTRA_APP_KEY_KEY
String EXTRA_CHANNEL_ID_KEY
String EXTRA_PAYLOAD_VERSION_KEY
int UNKNOWN_PLATFORM Unknown platform.
Fields
public static boolean LOG_TAKE_OFF_STACKTRACE Flag to enable printing take off's stacktrace.
Public Methods
boolean deepLink(String deepLink)
Deep links.
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 long getAppVersion()
Returns the current Application version.
static Context getApplicationContext()
Returns the current Application's context.
ApplicationMetrics getApplicationMetrics()
Returns the ApplicationMetrics instance.
AirshipChannel getChannel()
Returns the com.urbanairship.channel.AirshipChannel instance.
ChannelCapture getChannelCapture()
Returns the ChannelCapture instance.
Contact getContact()
Returns the Contact instance.
DeepLinkListener getDeepLinkListener()
Returns the deep link listener if one has been set, otherwise null.
Locale getLocale()
Get the locale stored in UAirship.
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.
PermissionsManager getPermissionsManager()
Returns the UAirship PermissionsManager instance.
int getPlatformType()
Returns the platform type.
PrivacyManager getPrivacyManager()
Returns the privacy manager.
PushManager getPushManager()
Returns the PushManager instance.
UrlAllowList getUrlAllowList()
The URL allow list is used to determine if a URL is allowed to be used for various features, including: Airship JS interface, open external URL action, wallet action, HTML in-app messages, and landing pages.
static String getVersion()
Returns the current Airship version.
boolean isDataCollectionEnabled()
This method is deprecated. Enable/disable by using PrivacyManager. This will call through to the privacy manager to check if any features are enabled.
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.
void setDataCollectionEnabled(boolean enabled)
This method is deprecated. Enable/disable by using PrivacyManager. This will enable or disable FEATURE_ALL features.
void setDeepLinkListener(DeepLinkListener listener)
Sets the deep link listener.
void setImageLoader(ImageLoader imageLoader)
Sets the image loader.
void setLocaleOverride(Locale locale)
Sets a locale to be stored in UAirship.
static UAirship shared()
Returns the shared UAirship singleton instance.
static Cancelable shared(Looper looper, UAirship.OnReadyCallback callback)
Requests the airship instance asynchronously.
static Cancelable shared(UAirship.OnReadyCallback callback)
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 FCM/HMS transport will be allowed.

Constant Value: 2 (0x00000002)

public static final String EXTRA_AIRSHIP_DEEP_LINK_SCHEME

Constant Value: "uairship"

public static final String EXTRA_APP_KEY_KEY

Constant Value: "app_key"

public static final String EXTRA_CHANNEL_ID_KEY

Constant Value: "channel_id"

public static final String EXTRA_PAYLOAD_VERSION_KEY

Constant Value: "payload_version"

public static final int UNKNOWN_PLATFORM

Unknown platform. Returns if all features have been disabled in PrivacyManager.

Constant Value: -1 (0xffffffff)

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 boolean deepLink (String deepLink)

Deep links. If the deep link is an `uairship://` it will be handled internally by the SDK. All other deep links will be forwarded to the deep link listener.

Parameters
deepLink The deep link.
Returns
  • true if the deep link was handled, otherwise false.

public ActionRegistry getActionRegistry ()

The default Action Registry.

Returns
  • The 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 long getAppVersion ()

Returns the current Application version.

Returns
  • The version, or -1 if the package cannot be read.

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 AirshipChannel getChannel ()

Returns the com.urbanairship.channel.AirshipChannel instance.

Returns
  • The com.urbanairship.channel.AirshipChannel instance.

public ChannelCapture getChannelCapture ()

Returns the ChannelCapture instance.

Returns

public Contact getContact ()

Returns the Contact instance.

Returns
  • The Contact instance.

public DeepLinkListener getDeepLinkListener ()

Returns the deep link listener if one has been set, otherwise null.

Returns
  • The deep link listener.
Throws
IllegalStateException if takeOff has not been called.

public Locale getLocale ()

Get the locale stored in UAirship.

Returns
  • The locale stored in UAirship, if none, return the default Locale from the device.

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 PermissionsManager getPermissionsManager ()

Returns the UAirship PermissionsManager instance.

Returns

public int getPlatformType ()

Returns the platform type.

Returns

public PrivacyManager getPrivacyManager ()

Returns the privacy manager.

Returns
  • The privacy manager.

public PushManager getPushManager ()

Returns the PushManager instance.

Returns

public UrlAllowList getUrlAllowList ()

The URL allow list is used to determine if a URL is allowed to be used for various features, including: Airship JS interface, open external URL action, wallet action, HTML in-app messages, and landing pages.

Returns
  • The urlAllowList.

public static String getVersion ()

Returns the current Airship version.

Returns
  • The Airship version number.

public boolean isDataCollectionEnabled ()

This method is deprecated.
Enable/disable by using PrivacyManager. This will call through to the privacy manager to check if any features are enabled.

Deprecated. Use PrivacyManager instead. Checks if any features are enabled in the privacy manager.

Returns
  • true if any feature is enabled, otherwise `false`.

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 void setDataCollectionEnabled (boolean enabled)

This method is deprecated.
Enable/disable by using PrivacyManager. This will enable or disable FEATURE_ALL features.

Deprecated. Use PrivacyManager instead. When enabled it will enable all privacy manager features. When disabled it will disable all.

Parameters
enabled true to enable, false to disable.

public void setDeepLinkListener (DeepLinkListener listener)

Sets the deep link listener.

Parameters
listener the deep link listener.

public void setImageLoader (ImageLoader imageLoader)

Sets the image loader.

Parameters
imageLoader The image loader.

public void setLocaleOverride (Locale locale)

Sets a locale to be stored in UAirship.

Parameters
locale The new locale to use.

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 (Looper looper, UAirship.OnReadyCallback callback)

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
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.
callback An optional callback
Returns
  • A cancelable object that can be used to cancel the callback.

public static Cancelable shared (UAirship.OnReadyCallback callback)

Requests the airship instance asynchronously.

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

Parameters
callback An optional callback
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. If the callback takes longer than ~5 seconds it could cause ANRs within the application.

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. If the callback takes longer than ~5 seconds it could cause ANRs within the application.