The SDK can be integrated into a Ionic project.
Application’s onCreate function on Android.AppDelegate’s didFinishLaunchingWithOptions function on iOS.HumanManager object that will handle calls from Ionic side.Here is an example of how it should be:
Java / MainApplication.java:
Java / HumanManager.kt:
Java / MainActivity.java:
Swift / AppDelegate.swift:
Swift / HumanManager.swift:
Objective-C / HumanManagerPlugin.m:
Let’s talk about what we have in the code here:
HSPolicy instance. This object is used to configure the SDK’s behavior. Here, we set the HSAutomaticInterceptorPolicy/interceptorType property to HSAutomaticInterceptorType/none. This means that the Automatic Interception feature of the SDK is disabled. In short, this feature allows the SDK to manipulate URL requests and handle their responses by itself. However, this feature is not supported in Ionic.HumanSecurity/start(appId:policy:) function of the SDK. We provide the following parameters:
Application instance (Android only).HSBotDefender/handleBlockResponse function. This function will present a challenge to the user when the provided response is a blocked response.Note: If your app communicates with several servers that have different AppID, you can call the HumanSecurity/start(appIds:policy:) function which allow you to pass an array of AppIDs. You should specify the relevant AppID for each API call in the SDK.
In your Javascript code, you should do the following:
HumanManager plugin.Here is an example of how it should be:
Javascript:
The HUMAN’s Enforcer, when it decides to block a request, returns a JSON string in the response’s body. The HTTP status code is 403. Here is an example of the response:
The JSON contains metadata for the SDK.
Your app should pass the whole JSON to the SDK via the HSBotDefender/handleBlockResponse function. Otherwise, the SDK won’t present a challenge to the user.