-
public interface IHCaptchahCaptcha client which allows invoking of challenge completion and listening for the result.
Usage example: 1. Get a client either using the site key or customize by passing a config: client = HCaptcha.getClient(this).verifyWithHCaptcha(YOUR_API_SITE_KEY) client = HCaptcha.getClient(this).verifyWithHCaptcha(com.hcaptcha.sdk.HCaptchaConfig) // Improve cold start by setting up the hCaptcha client client = HCaptcha.getClient(this).setup(com.hcaptcha.sdk.HCaptchaConfig) // ui rendering... // user form fill up... // ready for human verification client.verifyWithHCaptcha(); 2. Listen for the result and error events: client.addOnSuccessListener(new OnSuccessListener{@literal <}HCaptchaTokenResponse{@literal >}() {{@literal @}Override public void onSuccess(HCaptchaTokenResponse response) { String userResponseToken = response.getTokenResult(); Log.d(TAG, "hCaptcha token: " + userResponseToken); // Validate the user response token using the hCAPTCHA siteverify API } }) .addOnFailureListener(new OnFailureListener() {{@literal @}Override public void onFailure(HCaptchaException e) { Log.d(TAG, "hCaptcha failed: " + e.getMessage() + "(" + e.getStatusCode() + ")"); } });
-
-
Method Summary
Modifier and Type Method Description abstract HCaptchasetup()Prepare the client which allows to display a challenge dialog abstract HCaptchasetup(@NonNull() String siteKey)Constructs a new client which allows to display a challenge dialog abstract HCaptchasetup(@NonNull() HCaptchaConfig config)Constructs a new client which allows to display a challenge dialog abstract HCaptchaverifyWithHCaptcha()Shows a captcha challenge dialog to be completed by the user abstract HCaptchaverifyWithHCaptcha(@NonNull() String siteKey)Shows a captcha challenge dialog to be completed by the user abstract HCaptchaverifyWithHCaptcha(@NonNull() HCaptchaConfig config)Shows a captcha challenge dialog to be completed by the user abstract voidreset()Force stop verification and release resources. -
-
Method Detail
-
setup
abstract HCaptcha setup(@NonNull() String siteKey)
Constructs a new client which allows to display a challenge dialog
- Parameters:
siteKey- The hCaptcha site-key.
-
setup
abstract HCaptcha setup(@NonNull() HCaptchaConfig config)
Constructs a new client which allows to display a challenge dialog
- Parameters:
config- Config to customize: size, theme, locale, endpoint, rqdata, etc.
-
verifyWithHCaptcha
abstract HCaptcha verifyWithHCaptcha()
Shows a captcha challenge dialog to be completed by the user
-
verifyWithHCaptcha
abstract HCaptcha verifyWithHCaptcha(@NonNull() String siteKey)
Shows a captcha challenge dialog to be completed by the user
- Parameters:
siteKey- The hCaptcha site-key.
-
verifyWithHCaptcha
abstract HCaptcha verifyWithHCaptcha(@NonNull() HCaptchaConfig config)
Shows a captcha challenge dialog to be completed by the user
- Parameters:
config- Config to customize: size, theme, locale, endpoint, rqdata, etc.
-
reset
abstract void reset()
Force stop verification and release resources.
-
-
-
-