How to upgrade from v3
Major Changes in the SDK's API
This article covers the major changes in the SDK's API.
Bye Bye PerimeterX... Hello HumanSecurity
-
SDK Name Change:
- The SDK name has been changed from PerimeterX to HUMAN.
- Android:
import com.humansecurity.mobile_sdk.HumanSecurity
- iOS:
import HUMAN
- Android:
- The SDK name has been changed from PerimeterX to HUMAN.
-
Repository Update for Android:
- Update your
build.gradle
file to use the new SDK repository location:https://jfrog.humansecurity.com/artifactory/human-android-sdk/
- Update your
-
Class Renaming:
- The main class has been renamed from
PerimeterX
toHumanSecurity
. - All SDK classes now have the
HS
prefix instead ofPX
.
- The main class has been renamed from
-
Function Relocation:
- Some functions previously in
PerimeterX
have been moved toHSBotDefender
andHSAccountDefender
classes based on their context.
- Some functions previously in
-
Delegate Renaming:
PerimeterXDelegate
has been renamed toHSBotDefenderDelegate
.
-
Error Handling:
- Error query functions have been consolidated into the
HSBotDefender/errorType(error:)
function.
- Error query functions have been consolidated into the
-
Removal of
HSTimeoutInterceptor
(Android):- The
HSTimeoutInterceptor
class has been removed. - You can now set different timeouts directly in the OkHttp client configuration.
- The
The Policy
-
Policy Object Structure:
- Before: The policy object was a single-level object that included all SDK configurations.
- Now: The policy object includes the following nested objects:
HSAutomaticInterceptorPolicy
- Configurations for "Automatic Interceptor".HSHybridAppPolicy
- Configurations for "Hybrid App".HSDetectionPolicy
- Configurations related to the SDK's detection mechanisms.HSDoctorAppPolicy
- Configurations for the "Doctor App".
-
Server Domain Configuration:
- Before: You had to set your server(s) domain(s) for both "Automatic Interceptor" and "Hybrid App" within the same function.
- Now: There are separate functions for setting domains for each policy.
Bot Defender
headersForURLRequest
Function:- Before: The
HSBotDefender/headersForURLRequest(forAppId:)
function returnednil
ornull
if called beforeHumanSecurity/start(appId:policy:)
. - Now: This function will always return a value (never empty). However, it must be called after
HumanSecurity/start(appId:policy:)
.
- Before: The
Hybrid App
- Enabling Hybrid App:
- To enable "Hybrid App," call the
HSHybridAppPolicy/set(webRootDomains:forAppId:)
function. - Note: You should set the web root domain (e.g.,
.example.com
).
- To enable "Hybrid App," call the
New in iOS
-
Manual Integration:
- The
HumanSecurity/setupWebView(webView:navigationDelegate:)
function allows for manual "Hybrid App" integration, unlike the automatic method available in previous versions.
- The
-
Automatic Setup Option:
- The
HSHybridAppPolicy/automaticSetup
option enables the same automatic "Hybrid App" integration that was available in previous versions.
- The
Environment
Android
-
SDK Build Specifications:
- The SDK is now built for API 35 and Kotlin 2.1.0.
-
New Dependencies:
-
The SDK has a new list of dependencies (see below). When fetching the SDK from our Artifactory, these dependencies are automatically included.
-
Note: If you need to change the version of some dependencies, you may integrate the SDK manually and select the exact versions that work for your app.
implementation 'androidx.core:core-ktx:1.15.0' // any version (select 1.10.1 if your app has 'targetSdkVersion 33') implementation 'androidx.lifecycle:lifecycle-process:2.8.7' // min v2.6.0 (select 2.6.2 if your app has 'targetSdkVersion 33') implementation 'androidx.datastore:datastore-preferences:1.1.1' // any version (select 1.0.0 if your app targets API 33) implementation 'com.google.android.material:material:1.12.0' // min v1.6.0 (select 1.9.0 if your app has 'targetSdkVersion 33') implementation 'com.fasterxml.uuid:java-uuid-generator:4.3.0' // min v3.0.0 implementation 'io.ktor:ktor-client-okhttp:3.0.3' // min v3.0.0
-
Updated 7 days ago