For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HUMAN DashboardHUMAN WebsiteRequest a Demo
Product GuidesEnforcer GuidesMobile SDKAPI ReferenceCustomer support
Product GuidesEnforcer GuidesMobile SDKAPI ReferenceCustomer support
    • Overview
  • Mobile SDK (for Android, iOS, and visionOS)
    • Android changelog
    • iOS, iPadOs, & visionOS changelog
    • Expo changelog
    • React Native Wrapper changelog
  • iOS SDK
    • What's New
      • How to integrate the SDK in your application
      • How to verify the integration in your app with the SDK
      • Callbacks from the SDK
      • How to retry blocked requests
      • Multiple AppIDs support
      • Integration with React Native
      • Integration with gRPC [BETA]
      • Migrating SDK from v1 to v2
    • How to test your app with the SDK
  • Android SDK
    • What's New
    • How to test your app with the SDK
LogoLogo
Login
Login
HUMAN DashboardHUMAN WebsiteRequest a Demo
On this page
  • v2.x
  • The SDK is ready
  • A request was blocked
  • A challenge was solved by the user
  • A challenge was cancelled by the user
iOS SDKv2

Callbacks from the SDK

Was this page helpful?
Previous

How to retry blocked requests

Next
Built with

v2.x

The SDK provides callbacks that will help you to handle events from it. There are 4 types of events:

  1. The SDK is ready.
  2. A request was blocked.
  3. A challenge was solved by the user.
  4. A challenge was cancelled by the user.

The SDK is ready

This event means that the SDK was finished the start process successfully. When calling the PerimeterX/start(appId:delegate:enableDoctorCheck:completion:) function, you should provide a completion handler. Once the handler is called with success == true you know that the SDK is ready. In addition, you can register to this event in other places within your code, using the PerimeterX/addInitializationFinishedCallback(forAppId:callback:) function. Here is an example:

1PerimeterX.addInitializationFinishedCallback(forAppId: nil) {
2 print("PerimeterX is ready")
3}

You can call the PerimeterX/addInitializationFinishedCallback(forAppId:callback:) when the SDK is already ready. In this case, the callback will be called immediately.

A request was blocked

This event occurred when a request was blocked by PerimeterX. Notice that this event is only for native URL requests. URL requests which are origin from web views won’t trigger this event.

There are two ways to receive this event:

  1. PerimeterX’s delegate - The delegate object that conform to the PerimeterXDelegate protocol should implement the PerimeterXDelegate/perimeterxDidRequestBlocked(forAppId:) function.
  2. Register to the event - you can register to this event in other places within your code, using the PerimeterX/registerCallbackForRequestBlockedEvent(forAppId:callback:) function. This function returns a Registration ID which can be used to unregister from this event with the PerimeterX/unregisterCallbackForRequestBlockedEvent(forAppId:registrationId:). Here is an example:
1let requestBlockedEventRegistrationId = PerimeterX.registerCallbackForRequestBlockedEvent {
2 print("Request Blocked Event")
3}

A challenge was solved by the user

This event occurred when a challenge was solved by the user. Notice that this event is only for native URL requests. URL requests which are origin from web views won’t trigger this event.

There are two ways to receive this event:

  1. PerimeterX’s delegate - The delegate object that conform to the PerimeterXDelegate protocol should implement the PerimeterXDelegate/perimeterxDidChallengeSolved(forAppId:) function.
  2. Register to the event - you can register to this event in other places within your code, using the PerimeterX/registerCallbackForChallengeSolvedEvent(forAppId:callback:) function. This function returns a Registration ID which can be used to unregister from this event with the PerimeterX/unregisterCallbackForChallengeSolvedEvent(forAppId:registrationId:). Here is an example:
1let challengeSolvedEventRegistrationId = PerimeterX.registerCallbackForChallengeSolvedEvent {
2 print("Challenge Solved Event")
3}

A challenge was cancelled by the user

This event occurred when a challenge was cancelled by the user. Notice that this event is only for native URL requests. URL requests which are origin from web views won’t trigger this event.

There are two ways to receive this event:

  1. PerimeterX’s delegate - The delegate object that conform to the PerimeterXDelegate protocol should implement the PerimeterXDelegate/perimeterxDidChallengeCancelled(forAppId:) function.
  2. Register to the event - you can register to this event in other places within your code, using the PerimeterX/registerCallbackForChallengeCancelledEvent(forAppId:callback:) function. This function returns a Registration ID which can be used to unregister from this event with the PerimeterX/unregisterCallbackForChallengeCancelledEvent(forAppId:registrationId:). Here is an example:
1let challengeCancelledEventRegistrationId = PerimeterX.registerCallbackForChallengeCancelledEvent {
2 print("Challenge Cancelled Event")
3}