fun initClient()

in android/src/main/java/com/google/recaptchaenterprisereactnative/RecaptchaEnterpriseReactNativeModule.kt [69:90]


  fun initClient(siteKey: String, arguments: ReadableMap, promise: Promise) {
    GlobalScope.launch {
      let {
        if (arguments.hasKey("timeout")) {
          // JS+ReadableMap have no support for long
          val timeout = arguments.getDouble("timeout").toLong()
          Recaptcha.getClient(application, siteKey, timeout)
        } else {
          Recaptcha.getClient(application, siteKey)
        }
      }
      .onSuccess { client ->
        recaptchaClient = client
        promise.resolve(null)
      }
      .onFailure { exception ->
        if (exception is RecaptchaException) { promise.reject(exception.errorCode.toString(), exception.errorMessage, exception) } else {
          promise.reject(exception)
        }
      }
    }
  }