Implementing TUNE iOS SDK 4.12.0

Updating to iOS 4.12.0

Have an existing TUNE SDK implementation? Several methodsĀ are deprecated for iOS 4.12.0. Update and change to the following methods:

  • If you are calling checkForDeferredDeeplink: change to registerDeeplinkListener:
  • If you are calling applicationDidOpenURL:sourceApplication: change to handleOpenURL:sourceApplication: or handleOpenURL:options:
  • If you are calling application:tuneContinueUserActivity:restorationHandler: change to handleContinueUserActivity:restorationHandler:

Implementing TUNE SDK 4.12.0

The deep link implementation uses one listener to handle both deferred and universal links.

Add Hooks to AppDelegate Methods

Add hooks into your AppDelegate's application:openURL:options and application:openURL:sourceApplication:annotation: methods, calling TUNE's handleOpenURL:options or handleOpenURL:sourceApplication: in order to capture app opens from a URL scheme:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {
    // Pass the deep link URL to Tune
    [Tune handleOpenURL:url options:options];
    // Take care of the redirect yourself here
    ...
    return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    // Pass the deep link URL to Tune
    [Tune handleOpenURL:url sourceApplication:sourceApplication];
    // Take care of the redirect yourself here
    ...
    return YES;
}

Add a hook into your AppDelegate's application:continueUserActivity:restorationHandler: method, calling TUNE's handleContinueUserActivity:restorationHandler: in order to capture app opens from a Universal Link:

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray * _Nullable))restorationHandler {
    BOOL handledByTune = [Tune handleContinueUserActivity:userActivity restorationHandler:restorationHandler];
    // If handledByTune is false, take care of the redirect yourself
    if (!handledByTune) {
        ...
    }
    return YES;
}

To implement, call registerDeeplinkListener: with a TuneDelegate implementation after your TUNE SDK init call. The implementation must implement the methods tuneDidReceiveDeeplink: and tuneDidFailDeeplinkWithError:

For example, you can have your app delegate implement the following TuneDelegate callbacks:

- (void)tuneDidReceiveDeeplink:(NSString *)deeplink {
    NSLog(@"TUNE.deeplink: %@", deeplink);
    // Handle deep link redirect here...
}

- (void)tuneDidFailDeeplinkWithError:(NSError *)error {
    NSLog(@"TUNE.deeplink failed: %@", [error localizedDescription]);
}

Then register itself as a listener:

[Tune registerDeeplinkListener:self];

You are now able to track a variety of deeplink opens with the TUNE SDK.

Have a Question? Please contact support@tune.com for technical support.