If necessary, the application handle all links to websites or social media itself. The TickarooSDKDelegate protocol provides the necessary callback for this.

- (BOOL)tickarooSDK:(TickarooSDK *)tickarooSDK navigateToRef:(TApiAbstractRef *)ref;

with this method the TickarooSDK asks the delegate if it wants to handle an ref (type:TApiAbstractRef; our object for cross-referencing data). If the delegate decides to handle a ref it needs to return true, telling the TickarooSDK to skip the default behavior. The most relevant ref for handling manually is the UrlRef (TikApiUrlRef).

interesting properties from TikApiUrlRef:

  • url NSString The url of the target

Example code for opening a web-link in safari:

Objective-C

- (BOOL)tickarooSDK:(TickarooSDK *)tickarooSDK navigateToRef:(TApiAbstractRef *)ref {
    if ([ref isKindOfClass:[TApiUrlRef class]]) {
        TApiUrlRef *urlRef = (TApiUrlRef *)ref;
        if ([urlRef.url hasPrefix:@"http"]) { // we want to handle http(s) urls ourself
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlRef.url] options:@{} completionHandler:nil]; // open this url in webbrowser
            return true; // tell the SDK to ignore this ref
        }
    }
    return false; // tell the SDK to use default behavior
}

Swift

func tickarooSDK(_ tickarooSDK: TickarooSDK!, navigateTo ref: TApiAbstractRef!) -> Bool {
    if let ref = ref as? TApiUrlRef, ref.url.hasPrefix("http"), let url = URL(string: ref.url) {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
        return true
    }
    
    return false
}