Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex SmartCaptcha
  • Getting started
    • CAPTCHA availability
    • User validation
    • Domain validation
    • Challenge types
    • Challenge options
    • Widget connection methods
    • CAPTCHA keys
    • Invisible CAPTCHA
    • CAPTCHA in React
    • JavaScript Interface object
    • Restricted mode
    • Public IP addresses
    • Quotas and limits
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • JavaScript Interface structure
  • onGetToken(token: String): Unit method
  • onChallengeVisible(): Unit method
  • onChallengeHidden(): Unit method
  1. Concepts
  2. JavaScript Interface object

JavaScript Interface object

Written by
Yandex Cloud
Updated at January 20, 2025
  • JavaScript Interface structure
    • onGetToken(token: String): Unit method
    • onChallengeVisible(): Unit method
    • onChallengeHidden(): Unit method

JavaScript Interface is an object Android transfers to WebView. The front end will then access this object to send messages using a callback function on Android.

JavaScript Interface structureJavaScript Interface structure

onGetToken(token: String): Unit methodonGetToken(token: String): Unit method

This is a required method, through which a token for passing CAPTCHA verification is transferred. It is called on the front end once the service has handled a user's attempt to pass CAPTCHA verification.

onChallengeVisible(): Unit methodonChallengeVisible(): Unit method

This is an optional method which you may only need to embed an invisible CAPTCHA. It is called when the invisible CAPTCHA shows a challenge to the user. By default, WebView with invisible CAPTCHA is hidden, so you need to track the moment when the WebView needs to be displayed.

onChallengeHidden(): Unit methodonChallengeHidden(): Unit method

This is an optional method which you may only need to embed an invisible CAPTCHA. If the user swiped CAPTCHA off, they cannot restore it on their own; you will need to show the previous screen to the user.

Note

When creating a class, the above methods are marked with the @JavascriptInterface annotation.
If you develop your own website with CAPTCHA, you can change the names of these methods. In this case, you will need to change the method names on the front-end side, too.

Was the article helpful?

Previous
CAPTCHA in React
Next
Restricted mode
© 2025 Direct Cursus Technology L.L.C.