tiktok/tiktok-opensdk-ios

When some users are authorized to log in, they will jump to an external browser to open the tiktok web page, but "authRequest?.isWebAuth" is false.

Opened this issue · 0 comments

When some users are authorized to log in, they will jump to an external browser to open the tiktok web page, but "authRequest?.isWebAuth" is false.

my tiktok sdk version is 2.2.0,

pod 'TikTokOpenSDKCore'
 pod 'TikTokOpenAuthSDK'

my code :

@objc
  public static func getAuthCode(scopes: NSString,resolver:@escaping RCTPromiseResolveBlock,rejecter:@escaping RCTPromiseRejectBlock)->Void{
    resolve = resolver;
    reject = rejecter;
    
    let scopesArray:Array = scopes.components(separatedBy: ",");
    var setScopes: Set<String> = [];
    let redirectUri = "https://m.iboominggxxx.xx/"
    let dict = NSMutableDictionary();
    var authRequest: TikTokAuthRequest?

    for index in 0 ..< scopesArray.count {
      setScopes.insert(scopesArray[index])
    }
    print("===getAuthCode 1111111==== ",setScopes);
    
    authRequest = TikTokAuthRequest(scopes: setScopes, redirectURI:redirectUri)
    authRequest?.isWebAuth = false
    
    DispatchQueue.main.sync {
      authRequest?.send { response in
        guard  let myresponse = response as? TikTokAuthResponse else {
          let errorObj = NSError(domain: "getAuthCode fail", code: -1);
          authRequest = nil
          reject?("getAuthCode fail","myresponse is null!",errorObj);
          return }

        if myresponse.errorCode != .noError {
          let message = "Error: \(myresponse.error ?? ""),code:\(String(myresponse.errorCode.rawValue)), Error Description: \(myresponse.errorDescription ?? "")"
          let errorObj = NSError(domain: message, code: myresponse.errorCode.rawValue);
            reject?("getAuthCode fail","errorCode is error! ",errorObj);
        }else{
          dict.setValue(myresponse.errorCode.rawValue, forKey:"errorCode")
          dict.setValue(myresponse.errorDescription, forKey:"errorMsg")
          dict.setValue(myresponse.authCode, forKey:"authCode")
          dict.setValue(scopes, forKey:"grantedPermissions")
          dict.setValue(authRequest?.pkce.codeVerifier, forKey:"codeVerifier")
          dict.setValue(redirectUri, forKey:"redirectUri")
          resolve?(dict)
          authRequest = nil
        }
        print("===getAuthCode 33333==== ", dict);
      }
    }
  }

//============= AppDelegate.m ===============
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  
  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
    return [RCTLinkingManager application:application openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  
  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
    return [RCTLinkingManager application:application openURL:url
                                 sourceApplication:sourceApplication annotation:annotation];
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{

  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
  return NO;
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler{

   BOOL result = [TTKSDKURLHandler handleOpenURL:userActivity.webpageURL];
   NSLog(@"=========== restorationHandler  ========%@  result=%d",userActivity.webpageURL,result);
   if(result){
      return true;
   }

  return false;
}

isWebAuth is false, so user only open tiktok app to authorize.

So it is very strange why the user can jump to an external browser and open the tiktok authorization login on the webpage.
This is video record.

Lark20240328-163421.mp4

Hope help, thank you!