This method allows you to track your universal links on your app when directed from your other Insider platforms (e.g. Email, Web Push).
Parameter | Data Type |
|---|---|
intent | Intent |
Method Examples
To handle universal links for the iOS platform:
1. Add the Insider handleUniversalLink iOS method in the continueUserActivity method you added to the AppDelegate for Linking.
2. Add the Insider handleUrl iOS method in the openURL method to handle Insider’s links.
The following code snippets show how to use this method in Objective-C and Swift.
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>
#import <InsiderMobile/Insider.h>
@implementation AppDelegate
...
...
...
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
// For Insider's links
if ([[url scheme] containsString:@"insider"]) {
[Insider handleUrl:url];
}
return [RCTLinkingManager application:application openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
// For univesal links
[Insider handleUniversalLink:userActivity];
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
@end
private func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
guard let encodedURL = userActivity.webpageURL else {
print("Unable to handle user activity: No URL provided")
return false
}
let task = URLSession.shared.dataTask(with: encodedURL, completionHandler: { (data, response, error) in
guard (response?.url) != nil else {
print("Unable to handle URL: \(encodedURL.absoluteString)")
return
}
Task { [userActivity]
}
Insider.handleUniversalLink(userActivity)
})
task.resume()
}
return true
}