Instrumenting iOS apps

This page explains how to enable and customize the reCAPTCHA Enterprise API in your iOS app. For more information about reCAPTCHA Enterprise, see the reCAPTCHA Enterprise overview.

Before you begin

  • Complete the steps in the Quickstart to gain access to the API.
  • Ask your sales representative to grant you access to the reCAPTCHA Enterprise CocoaPods repository and the download page.

Prepare your development environment

Download the SDK through CocoaPods

  1. Generate a git cookie by following these instructions.
  2. Add the following lines to your Podfile:

    source ""
    source ""
    pod "RecaptchaEnterprise", "16.0.3"
  3. Run pod update. This will take care of installing all required dependencies.

Download the SDK without CocoaPods

If you don't use CocoaPods, you can get the SDK binary directly in the download page.

Configure your app

  • Before starting your integration you need to create a reCAPTCHA iOS Key.

  • If your app is written in Swift, create an Objective-C bridging header and include the following import:

    #import <recaptcha/recaptcha.h>
  • Make sure -ObjC is listed on your linker flags:

Settings Setting Name Value
Target > Build Settings > All > Linking Other Linker Flags -ObjC

App integration

Create a sample app

  1. In XCode create a new blank iOS single view application.
  2. Instrument your sample project to integrate with CocoaPods and then with reCAPTCHA Enterprise.

Create the application

Step #1: Update ViewController.swift
  • Instantiate the SDK using:

       let recaptchaClient = RecaptchaClient(siteKey: "SomeSiteKey")

    Make sure to replace SomeSiteKey with the Key you created earlier.

  • Create a method that calls execute and retrieves a reCAPTCHA token:

    recaptchaClient.execute(RecaptchaAction(action: .login)).then { token in
      print("got token: \(token.recaptchaToken)")
    }.catch { error in
      print("got error: \(error)")
Step #2: Create a button to call reCAPTCHA

To trigger the code you just embedded in ViewController.swift, do the following:

  1. In the storyboard create a button.
  2. Link the button's action to the execute method created in the previous step.
Step #3: Test

To test your application:

  1. Clean your Xcode build environment. In the Product menu, click Clean Build Folder.
  2. To run the application, from the Product menu, click Run.
  3. In your loaded application click the reCAPTCHA button created earlier.
  4. Observe your debug output window, it should return a reCAPTCHA token (alpha-numeric string) if the integration was done correctly.
Create an Assessment

To validate the reCAPTCHA response token, follow the instructions to create an Assessment.

iOS API reference

Consult the api reference page.