我正在我的应用程序中使用TikTok实现社交登录,从官方文档中我实现了基本设置并与我的AppDelegate https://developers.tiktok.com/doc/getting-started-ios-quickstart-swift连接。使用这些示例代码实现了loginkit,但在我们从TikTok应用程序授权后,request.send completionBlock没有得到任何响应或没有进入完成块。如果有人在iOS中实现了tiktok登录工具包,请提供帮助。
/* 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
}
}发布于 2021-08-09 14:42:32
感谢作者的评论,我也明白了这一点。在我的例子中,项目中没有SceneDelegate,所以根据TikTok的文档,我在AppDelegate中实现了3个与url相关的方法:
1:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool2:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any)3:
func application(_ application: UIApplication, handleOpen url: URL) -> Bool文档还建议第一种方法应该使用默认值for options,这显然是错误的,所以我删除了它。
我还在第一种方法中实现了Firebase动态链接:
if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
self.handleDynamicLink(dynamicLink)
return true
}事实证明,如果您完全删除第一个方法,并将Firebase DL处理移动到方法#2,一切都开始工作!处理动态链接,最终调用TT的完成块
https://stackoverflow.com/questions/68379573
复制相似问题