func execute()

in ios/RecaptchaEnterpriseReactNative.swift [76:105]


  func execute(
    actionStr: String,
    arguments: NSDictionary,
    resolve: @escaping RCTPromiseResolveBlock,
    reject: @escaping RCTPromiseRejectBlock
  ) {
    guard let client = recaptchaClient else {
      reject("RN_EXECUTE_FAILED", "Initialize client first", nil)
      return
    }
    let action = mapAction(actionStr)

    let executeClosure: (String?, Error?) -> Void = { token, error -> Void in
      if let token = token {
        resolve(token)
      } else if let error = error {
        guard let error = error as? RecaptchaError else {
          reject("RN_CAST_ERROR", "Not a RecaptchaError", nil)
          return
        }
        reject(String(error.errorCode.rawValue), error.errorMessage, nil)
      }
    }

    if let args = arguments as? [String: Any], let timeout = args["timeout"] as? Double {
      client.execute(withAction: action, withTimeout: timeout, completion: executeClosure)
    } else {
      client.execute(withAction: action, completion: executeClosure)
    }
  }