For iOS apps that do not use Iterable's SDK, handle deep links sent from Iterable with code similar to the following:
Swift
let ITBL_DEEPLINK_REGEX = "/a/[a-zA-Z0-9]+" func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { guard let urlString = userActivity.webpageURL?.absoluteString else { return false } let customRouteCallback = { (routeURL: String) -> Bool in // <MAKE A CUSTOM CALL TO YOUR APP'S ROUTES HERE WITH THE 'routeURL'> // .... // return true if you have handled the routeURL, false otherwise return true } if isIterableDeepLink(urlString) { let trackAndRedirectTask = URLSession.shared.dataTask(with: URL(string: urlString)!) {(data, response, error) in _ = customRouteCallback(response!.url!.absoluteString) } trackAndRedirectTask.resume() return true } else { return customRouteCallback(urlString) } } private func isIterableDeepLink(_ urlString: String) -> Bool { guard let regex = try? NSRegularExpression(pattern: ITBL_DEEPLINK_REGEX, options: []) else { return false } return regex.firstMatch(in: urlString, options: [], range: NSMakeRange(0, urlString.count)) != nil }
Objective-C
#define ITBL_DEEPLINK_IDENTIFIER @"/a/[a-zA-Z0-9]+" - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler { NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:ITBL_DEEPLINK_IDENTIFIER options:0 error:NULL]; NSString *urlString = userActivity.webpageURL.absoluteString; NSTextCheckingResult *match = [regex firstMatchInString:urlString options:0 range:NSMakeRange(0, [urlString length])]; void (^customRouteCallback)(NSString *) = ^(NSString * routeURL) { // <MAKE A CUSTOM CALL TO YOUR APP'S ROUTES HERE WITH THE 'routeURL'> }; if (match == NULL) { customRouteCallback(urlString); } else { NSURLSessionDataTask *trackAndRedirectTask = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:urlString] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { customRouteCallback(response.URL.absoluteString); }]; [trackAndRedirectTask resume]; } return YES; }