Live Updates

Integrate Live Updates into your Unity app to update content in real-time without requiring an app update. AXP

View as Markdown

Live Updates are an Android-only feature. The liveUpdateManager module is a no-op on iOS.

For the push API method, see the Android Live Updates messaging guide. See also the Android Live Updates feature guide.

App setup

Live Updates require native Android setup that Unity does not generate. You must implement a Live Update handler in native Kotlin and register it for each type using a plugin extender.

Creating a handler

The Airship SDK supports two types of Live Update handlers:

  • NotificationLiveUpdateHandler — Displays a notification with a custom layout, with content updated by the Live Update.
  • CustomLiveUpdateHandler — Receives Live Update events and provides flexibility to display content using a custom implementation. This can be used to power home screen widgets, views embedded in the app, and more.

Implement a handler that reads the Live Update payload and displays your content. For a complete NotificationLiveUpdateHandler example that renders a custom notification layout with RemoteViews, see the Android Live Updates SDK documentation.

Registering a handler

Handlers must be registered with LiveUpdateManager to receive Live Update events. Register them once after TakeOff using the plugin extender.

@Keep
public final class AirshipExtender: AirshipPluginExtender {

    override fun onAirshipReady(context: Context) {
        LiveUpdateManager.shared().run {
            register(type = "notification", handler = SampleLiveUpdateHandler())
        }
    }

}

The extender also has to be declared in the Android manifest under the com.urbanairship.plugin.extender meta-data key, or it is never loaded. See Extend Airship for the manifest entry and the full extender class.

Note

The type used above, "notification", maps Live Update events to the corresponding handler in your app. The value can be any string that is unique across all handlers registered by an app. This also allows a single handler to manage multiple Live Updates that each have a unique name.

Starting Live Updates

Start a Live Update with Start. The type maps the Live Update to the handler registered in your native Android project, and the name uniquely identifies the Live Update.

Airship.Shared.liveUpdateManager.Start(new LiveUpdateStartRequest() {
    name = "sports-game-123",
    type = "notification",
    content = new Dictionary<string, object>() {
        { "team_one_score", 0 },
        { "team_two_score", 0 },
        { "status_update", "Game started!" },
    },
});

Updating Live Updates

Airship.Shared.liveUpdateManager.Update(new LiveUpdateUpdateRequest() {
    name = "sports-game-123",
    content = new Dictionary<string, object>() {
        { "team_one_score", 3 },
        { "team_two_score", 0 },
        { "status_update", "Game started!" },
    },
});

Ending Live Updates

Airship.Shared.liveUpdateManager.End(new LiveUpdateEndRequest() {
    name = "sports-game-123",
    content = new Dictionary<string, object>() {
        { "team_one_score", 9 },
        { "team_two_score", 6 },
        { "status_update", "Game over!" },
    },
});

Clearing all active Live Updates

During development, it can be useful to reset Live Update tracking on app launch so that any Live Updates start fresh, even if they were already started during a previous launch. To end all currently active Live Updates, call ClearAll.

Airship.Shared.liveUpdateManager.ClearAll();