Jump to: Migrating to TUNE iOS SDK 4.12.+ | Implementing TUNE SDK 4.12.0 | Add Hooks to AppDelegate Methods | Register Deeplinks
Migrating to TUNE iOS SDK 4.12.+
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 toregisterDeeplinkListener:
- If you are calling
applicationDidOpenURL:sourceApplication:
change tohandleOpenURL:sourceApplication:
orhandleOpenURL:options:
- If you are calling
application:tuneContinueUserActivity:restorationHandler:
change tohandleContinueUserActivity: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;
}
Register Deeplinks
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.