因公司發(fā)展需求需要封裝uniappiOS端的抖音登錄的插件。所以就著手集成iOS抖音三方登錄。
先按照抖音開發(fā)者平臺的教程文檔集成,發(fā)現(xiàn)超級的簡單,直接建項目pod一下就完了。先不要太開心,這只是踩坑的開始,由于對接抖音登錄的人比較少所以百度的資源也比較少。基本上也就兩三條,而且最后都是提交給抖音工單,直接讓等三天。崩潰。
踩坑一
頁面會報douyinv1opensdk這個白名單沒有添加,這個比較簡單直接在LSApplicationQueriesSchemes下加上白名單就行。
踩坑二 也是崩潰一個
可以正常跳轉(zhuǎn)抖音授權(quán),但是總是彈出來用戶未綁定應(yīng)用白名單。再三對照抖音文檔白名單添加的都沒問題,為啥一直提示。百度也找不到,在此吐槽一下抖音的文檔寫的有點過于簡單

image.png
最終經(jīng)過一天的嘗試終于給解決了直接上代碼:
DouyinOpenSDKAuthRequest *request = [[DouyinOpenSDKAuthRequest alloc] init];
request.permissions = [NSOrderedSet orderedSetWithObjects:@"user_info", @"trial.whitelist", nil];
WEAK(weakSelf)
[request sendAuthRequestViewController:[self currentViewController] completeBlock:^(DouyinOpenSDKAuthResponse * _Nonnull resp) {
STRONG(strongSelf,weakSelf)
NSString *alertString = nil;
if (resp.errCode == 0) {
alertString = [NSString stringWithFormat:@"Author Success Code : %@, permission : %@",resp.code, resp.grantedPermissions];
resp.errCode = 200;
} else{
alertString = [NSString stringWithFormat:@"Author failed code : %@, msg : %@",@(resp.errCode), resp.errString];
}
/*
DouyinOpenSDKSuccess = 0,
DouyinOpenSDKErrorCodeCommon = -1,
DouyinOpenSDKErrorCodeUserCanceled = -2,
DouyinOpenSDKErrorCodeSendFailed = -3,
DouyinOpenSDKErrorCodeAuthDenied = -4,
DouyinOpenSDKErrorCodeUnsupported = -5,
*/
if (callback) {
callback(@{
@"code":@(resp.errCode),
@"data":@{},
@"info":@"success"
},YES);
}
[strongSelf showMsg:alertString];
}];
trial.whitelist加載授權(quán)的后邊。真的是無語,文檔上一點提及都沒有。