Handle block responses from the server
- 26 Feb 2023
-
Print
-
DarkLight
Handle block responses from the server
- Updated on 26 Feb 2023
-
Print
-
DarkLight
v3.0
When the "Automatic Interceptor" is enabled, the SDK will generate an error object when the URL request was blocked or when the challenge was solved/cancelled.
Checking the error
You can check the error by using those APIs:
PerimeterX/isRequestBlockedError(error:)
- returnstrue
when the request was blocked.PerimeterX/isChallengeSolvedError(error:)
- returnstrue
when the request was blocked and the user solved the challenge.PerimeterX/isChallengeCancelledError(error:)
- returnstrue
when the request was blocked and the user cancelled the challenge.
When will you receive those errors
When the "Automatic Interceptor" is enabled, the SDK will handle the block response from your server. The SDK will return the following errors to your URL request's handler:
- "Request was blocked" - The URL request's handler will be called once the block response arrives to your app. A challenge will be presented to the user.
- "Challenge was solved" - The URL request's handler will be called once the challenge was solved by the user. You may retry the URL request after getting this error.
- "Challenge was cancelled" - The URL request'a handler will be called once the challenge was cancelled by the user.
How the SDK presents the block page to the user
When the SDK receives the block response from the server it performs the following actions:
- Presenting a
block activity
in the app, over your other activities. - In the
block activity
the SDK presents a web view which loads the challenge that must be solved by the user (or the bot). - Once the challenge is solved, the SDK removes the
block activity
and allow the user to continue working in your app.
Was this article helpful?