Enable support for Account Defender
  • 09 Nov 2023
  • Dark
    Light

Enable support for Account Defender

  • Dark
    Light

Article Summary

In order to enable Account Defender, a user ID must be set. You can set it by calling the PerimeterX/setUserId(userId:forAppId:) function with a non null value. When the current user logout, you should call this function again with null. This will turn off the Account Defender. 

try {
    PerimeterX.setUserId("<the current user ID>", null)
}
catch {
    println("error: ${exception.message}")
}
try {
    PerimeterX.INSTANCE.setUserId("<the current user ID>", null);
}
catch {
    Log.e("tag","error: " + exception.getMessage());
}

In order to tell Account Defender about the user's flow, you should call the PerimeterX/registerOutgoingUrlRequest(url:forAppId:) function for each URL request that been send to your server. Notice that when the PXPolicy/urlRequestInterceptionType is set to any value rather than PXPolicyUrlRequestInterceptionType/none, the SDK registers URL requests automatically and you don't need to call this function.

try {
    PerimeterX.registerOutgoingUrlRequest("<URL>", null)
}
catch {
    println("error: ${exception.message}")
}
try {
    PerimeterX.INSTANCE.registerOutgoingUrlRequest("<URL>", null);
}
catch {
    Log.e("tag","error: " + exception.getMessage());
}

You may add additional data using the PerimeterX/setAdditionalData(parameters:forAppId:) function.

try {
    PerimeterX.setAdditionalData(hashMapOf("key1" to "key2", "key2" to "value2"), null)
}
catch {
    println("error: ${exception.message}")
}
try {
    HashMap<String, String> additionalData = new HashMap<>();
    additionalData.put("key1", "value1");
    additionalData.put("key2", "value2");
    PerimeterX.INSTANCE.setAdditionalData(additionalData, null);
}
catch {
    Log.e("tag","error: " + exception.getMessage());
}

Was this article helpful?