Is there a way to open a TikTok user profile in the TikTok app instead of directing to the browser from our app? Let's use Twitter example as they allow it:
twitter://user?screen_name=(username)
Is there a way to open a TikTok user profile in the TikTok app instead of directing to the browser from our app? Let's use Twitter example as they allow it:
twitter://user?screen_name=(username)
The solution was found. If the app is installed on the phone and you try to launch a TikTok profile from
it will redirect you to the chosen profile in the app.
Just open the TikTok url for the username
Objective-C
NSURL *url = [NSURL URLWithString:@"https://www.tiktok.com/@tiktokusername"];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
Swift
UIApplication.shared.open(URL(string: "https://www.tiktok.com/@tiktokusername")!, options: [:], completionHandler: nil)
Okey, so had similar issue. I have a link to a tiktok profile to open the app:
let tiktokUrl = "tiktok://@userName"
Was opening like that:
let application = UIApplication.shared
guard let url = URL(string: tiktokUrl) else { return }
if application.canOpenURL(url) {
application.open(url, options: [:], completionHandler: nil)
return
}
}
It was working for a long time. But we just noticed, that now (not sure on which iOS exactly) it started to open only TikTok app, and not the profile
The fix is: fix URL. It should be: From:
let tiktokUrl = "tiktok://@userName"
To:
let appUrl = "https://www.tiktok.com/@userName
And opening, just use .open:
From:
application.open(url, options: [:], completionHandler: nil)
To:
application.open(url)
So 2 things to fix: URL address so it is https://www.tiktok.com/@userName and HOW you open. Do not pass these options
and completionHandler
, as with these it will still open only the TikTok app.
By the way, the previous way I used still works for all other social networks: youtube, facebook, Instagram, but I had issues ONLY with tiktok.
Hope that will save someones time in the future