TikTok Login — iOS
Enable TikTok Login in your iOS game by adding the TikTok SDK and a few config entries.
TikTok Login requires your game to be registered in the TikTok Developer Portal. Contact the Alogame team to get your TikTokClientKey — they will handle the portal registration and backend setup.
1. Add TikTok SDK via SPM
In Xcode → File → Add Package Dependencies, add:
https://github.com/tiktok/tiktok-opensdk-ios
Select these products for your app target:
TikTokOpenSDKCoreTikTokOpenAuthSDK
Add to your app target, not the Alogame SDK target.
2. Configure Info.plist
Add the following entries. Replace YOUR_TIKTOK_CLIENT_KEY with the key provided by the Alogame team.
<!-- TikTok client key -->
<key>TikTokClientKey</key>
<string>YOUR_TIKTOK_CLIENT_KEY</string>
<!-- URL scheme for TikTok callback -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_TIKTOK_CLIENT_KEY</string>
</array>
</dict>
</array>
<!-- Allow querying TikTok app -->
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tiktokopensdk</string>
<string>tiktoksharesdk</string>
<string>snssdk1180</string>
<string>snssdk1233</string>
</array>
3. Add Associated Domains
In Xcode → Signing & Capabilities → + Capability → Associated Domains, add:
applinks:dev-api-sdk.oeg.vn
applinks:api-sdk.oeg.vn
This enables Universal Links for the TikTok web auth fallback (when TikTok app is not installed).
4. Wire URL callbacks
SwiftUI App
@main
struct YourApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
_ = OEGManager.handleOpenURL(url, options: [:])
}
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { activity in
_ = OEGManager.handleContinueUserActivity(activity)
}
}
}
}
AppDelegate (Objective-C)
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [OEGManager handleOpenURL:url options:options];
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
return [OEGManager handleContinueUserActivity:userActivity];
}
continueUserActivity is required for TikTok login. TikTok SDK 2.x uses Universal Links for the auth callback — even when the TikTok app is installed. Without this method, TikTok redirects back to the app but the auth code is silently dropped and the login screen stays open.
5. That's it
TikTok login is built into the SDK's login UI. Once the client key is configured, the TikTok button appears automatically when you call showLogin.
[[OEGManager sharedManager] showLoginWithCallback:^(OEGActionType type, id response, BOOL success, NSError *error) {
if (success) {
NSString *token = [OEGManager getAPIToken];
NSString *uuid = [OEGManager getAPIUUID];
}
}];
Troubleshooting
| Symptom | Fix |
|---|---|
| TikTok button not showing | Confirm the Alogame team has enabled TikTok for your game |
| Login fails after TikTok app returns | Ensure both .onOpenURL and .onContinueUserActivity are wired (SwiftUI), or that both openURL and continueUserActivity are forwarded in your AppDelegate. TikTok SDK 2.x uses Universal Links — continueUserActivity is the critical callback. |
TTKSDKAuthRequest not found at runtime | Add TikTokOpenAuthSDK to your app target (not just the SDK) |
| Web auth doesn't return to app | Add Associated Domains (applinks:dev-api-sdk.oeg.vn) |