Deep Linking
Deep Linking provides a mechanism to open an application to a specific resource. The Airship SDK framework supports the opening of deep links via the payload of a notification, a link from a Rich App Page or the JavaScript Interface.
Airship provides ways to trigger deep links through its messaging features. To handle custom deep links, the application needs to be set up to handle the deep link.
Listening for deep links
The deep link listener should be set during the onAirshipReady callback.
airship.deepLinkListener = DeepLinkListener { deepLink: String ->
// handle deepLink
true
}
The deep link listener should be set during the onAirshipReady callback.
airship.setDeepLinkListener(deepLink -> {
// Handle the deepLink
return true;
});
Deep link listener should be set after takeOff.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, DeepLinkDelegate, ... {
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
...
// Call takeOff
Airship.takeOff(config, launchOptions: launchOptions)
// Set deepLinkDelegate after takeOff
Airship.shared.deepLinkDelegate = self
return true
}
@MainActor
func receivedDeepLink(_ deepLink: URL) async {
// handle deep link
}
...
}
Deep link listener should be set after takeOff.
@interface AppDelegate () <UADeepLinkDelegate, ...>
...
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
// Call takeOff
[UAirship takeOff:config launchOptions:launchOptions];
// Set deepLinkDelegate after takeOff
UAirship.shared.deepLinkDelegate = self;
return Yes;
}
...
- (void)receivedDeepLink:(nonnull NSURL *)url
completionHandler:(nonnull void (^)(void))completionHandler {
// Handle deepLink
completionHandler();
}
...
@end
Airship.addListener(EventType.DeepLink, (event) => {
const deepLink = event.deepLink;
});
Airship.onDeepLink.listen((event) {
var deepLink = event.deepLink;
// handle deepLink
});
document.addEventListener("urbanairship.deep_link", function(event) {
var deepLink = event.deepLink
// handle deep link
}, false)
// Not available via Airship.NET. Use native bindings:
UAirship.Shared.OnDeepLinkReceived += (string deepLink) => {
// handle deep link
};
// Not available via Airship.NETStandard. Use native bindings.
Airship.addEventListener(Airship.eventDeepLinkReceived, function (e) {
var deepLink = event.deepLink
// handle deep link
})
UAirship.Shared.OnDeepLinkReceived += (string deepLink) => {
// handle deep link
};
Airship deep links
The Airship SDK provides several internal deep links with the uairship://
scheme. These deep links are only handled
through Airship messaging features and are not externally exposed.
Provided deep links:
uairship://preferences/<PREFERENCE_CENTER_ID>
Deep links to a preference center.uairship://message_center
Deep links to the message center.uairship://message_center/<MESSAGE_ID>
Deep links to a message within the message center.uairship://app_settings
Deep links to the system app settings for the app."uairship://app_store?itunesID=<IOS_ITUNES_ID>"
Deep links to the app’s listing on the devices app store.
Any other uairship://
deep links that are not handled by Airship directly will be delivered to the DeepLinkDelegate
.
These deep links are common across devices with the Airship SDK, so do not expose these deep links directly. Instead,
an App can expose their own deep link that maps to an Airship deep link. For instance, you can expose
myapp://airship/preference/<PREFERENCE_CENTER_ID>
and then when the app handles the deep link it can ask Airship to
display the preference center.
Categories