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.
You must set up deep links for your project in the Airship dashboard and also set up their handling in your application.
Listening for deep links
The SDK provides a way to listen for deep links so you can handle them in your app.
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.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.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
});
Airship.onDeepLink((event) => {
var deepLink = event.deepLink
// handle deep link
});
await Airship.onDeepLink(event => {
var deepLink = event.deepLink
// handle deep link
});
// 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 internal 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 in the devices app store.
Any other uairship://
deep links that are not handled by Airship directly are delivered to the DeepLinkDelegate
.
These deep links are common across devices with the Airship SDK, so do not expose them 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 when the app handles the deep link, it can ask Airship to
display the preference center.
Testing deep links
Testing deep links is critical for ensuring the correct user experience in your app. After setting up deep links, you can use the Deep Link ActionA configurable behavior that occurs when a user interacts with your message, e.g., opening a web page. in messages.
You can select a deep link when configuring:
- An ActionA configurable behavior that occurs when a user interacts with your message, e.g., opening a web page. in a Message, Automation, A/B Test, or Sequence.
- An action in in-app experiences.
- An action when creating content using the WYSIWYG editor.
- The Link element in a rich pageA landing page or Message Center message in your app that can include HTML, video, etc. template. See:
Categories