I am implementing social login with TikTok in my app, From official documentation I implemented Basic setup and connected with my AppDelegate https://developers.tiktok.com/doc/getting-started-ios-quickstart-swift. Implemented loginkit with there sample code but request.send completionBlock is not getting any response or do not enter into completion block after we authorised from TikTok app. Please help if any one has implemented tiktok login kit in iOS.
/* STEP 1 */
let scopes = "user.info.basic,video.list" // list your scopes
let scopesSet = NSOrderedSet(array:scopes)
let request = TikTokOpenSDKAuthRequest()
request.permissions = scopesSet
/* STEP 2 */
request.send(self, completion: { resp -> Void in
/* STEP 3 */
if resp.errCode == 0 {
/* STEP 3.a */
let clientKey = ... // you will receive this once you register in the Developer Portal
let responseCode = resp.code
// replace this baseURLstring with your own wrapper API
let baseURlString = "https://open-api.tiktok.com/demoapp/callback/?code=\(responseCode)&client_key=\(clientKey)"
let url = NSURL(string: baseURlstring)
/* STEP 3.b */
let session = URLSession(configuration: .default)
let urlRequest = NSMutableURLRequest(url: url! as URL)
let task = session.dataTask(with: urlRequest as URLRequest) { (data, response, error) -> Void in
/* STEP 3.c */
}
task.resume()
} else {
// handle error
}
}
Thanks to author's comment I figured that out too. In my case, there was no SceneDelegate in the project, so I had 3 url-related methods implemented in AppDelegate as per TikTok's documentation:
1:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool
2:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any)
3:
func application(_ application: UIApplication, handleOpen url: URL) -> Bool
The docs also suggested that 1st method should use a default value of [:] for options, which is plainly wrong so I removed it.
I also had Firebase dynamic links implemented in the 1st method:
if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
self.handleDynamicLink(dynamicLink)
return true
}
Turns out, if you remove the 1st method completely and move Firebase DL handling to method #2 everything starts working! Dynamic links are handled and TT's completion block finally gets called