Deeplinking

URLs present in notifications and mobile landings/in-app messages are handled by the Batch SDK in the following ways:

  • the default implementation by the SDK will automatically call -[UIApplication openURL:] with any URL it encounters
  • alternatively you can use a BatchDeeplinkDelegate to handle the URL your way
  • Objective-C
  • Swift
id<BatchDeeplinkDelegate> delegate;
// deeplinkDelegate is a class property of the Batch class
Batch.deeplinkDelegate = delegate;

// Then make your delegate implement the only method from the BatchDeeplinkDelegate protocol
- (void)openBatchDeeplink:(nonnull NSString*)deeplink;

The SDK references your delegate weakly so make sure you hold a strong reference to it. A good idea could be to use your application delegate as the deeplink delegate.

Universal links let you connect to content deep inside your app using standard HTTP or HTTPS links (see documentation on the Apple Developper website).

Universal links cannot be opened from within an app that supports them. That is to say, even if you have configured your app to handle universal links, you will need to use a deeplink delegate to manually redirect the user from the delegate method.

Custom URL schemes

Custom URL schemes, like customScheme://first-page, provide a way to reference resoures inside your app (see documentation on the Apple Developper website).

This type of URL is properly handled without a deeplink delegate. However, if you find yourself using a deeplinkg delegate, you will need to pass your custom-scheme URL manually to -[UIApplication openURL:]. This is a necessary step, considering setting a deeplink delegate overrides the default implementation of the SDK.