A deep link is a URI that links to a specific location within your mobile app. The following sections describe how to work with deep links using Iterable's Mobile SDKs.
NOTES
You should be able to use the same schema (pre-defined paths for presenting deep linking to a user) as your email or third party deep links.
In this article
iOS deep links
WARNING
By default, iOS apps can open HTTPS URLs, but not HTTP. Because of this, you should use HTTPS whenever possible. However, it is possible to configure your iOS apps to work with HTTP URLs by configuring App Transport Security exceptions in Xcode.
Push notifications and action buttons may have openUrl
actions attached to
them. When a URL is specified, the SDK first calls the urlDelegate
object
specified on your IterableConfig
object. You can use this delegate to
handle openUrl
actions the same way as you handle normal deep links. If the
delegate is not set or if it returns false
(the default), the SDK will open
the URL with Safari. If, upon receiving a deep link, you want to navigate to
a specific view controller in your app, do so in the urlDelegate
.
In the code below, DeepLinkHandler
is a custom handler which is reponsible
for deep link navigation. You have to provide an implementation for deep link
navigation. Please see the sample application
for a reference implementation for DeeplinkHandler
.
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // ... // Initialize Iterable SDK let config = IterableConfig() // ... config.urlDelegate = self IterableAPI.initialize(apiKey: "<YOUR-API-KEY>", launchOptions: launchOptions, config: config) } // Iterable URL delegate. It will be called when you receive // an `openUrl` event from push notification. func handle(iterableURL url: URL, inContext context: IterableActionContext) -> Bool { return DeeplinkHandler.handle(url: url) }
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // ... // Initialize Iterable SDK IterableConfig *config = [IterableConfig new]; // ... config.urlDelegate = self; [IterableAPI initializeWithApiKey:@"<YOUR-API-KEY>" launchOptions:launchOptions config:config]; } // Iterable URL delegate. It will be called when you receive // an `openUrl` event from push notification. - (BOOL)handleIterableURL:(NSURL *)url context:(IterableActionContext *)context { return [DeeplinkHandler handleUrl:url]; }
Android deep links
Handling links from push notifications
Push notifications and action buttons may have openUrl
actions attached to
them. When a URL is specified, the SDK first calls the urlHandler
specified
in your IterableConfig
object. You can use this class to handle openUrl
actions the same way as you handle normal deep links. If the handler is not
set or returns NO, the SDK will open a browser with that URL.
// MyApplication.java @Override public void onCreate() { super.onCreate(); // ... IterableConfig config = new IterableConfig.Builder() .setUrlHandler(this) .build(); IterableApi.initialize(context, "YOUR API KEY", config); } @Override public boolean handleIterableURL(Uri uri, IterableActionContext actionContext) { // Assuming you have a DeepLinkHandler class that handles all deep link URLs and navigates to the right place in the app return DeepLinkHandler.handle(this, uri); }