Skip to content

bespot/Antifraud-SDK-Android-Release

Repository files navigation

Antifraud SDK Android Release

VERSION API

Antifraud SDK is an easy to use Android library for protecting your application from fraudulent activities. Our SDK requires minimal permissions and uses device information and sensors to detect and report potential threats, so that app developers can make informed decisions about their application's actions.

Features

Detection Supported Description
VPN yes Virtual Private Network
Mock Location yes Another app is manipulating the device's location
Multiple Users yes More than one users are registered in the device

Installation

Add the following lines inside the dependencyResolutionManagement block of your settings.gradle.kts (or inside the repositories block of the root build.gradle.kts file if you still use the old way)

dependencyResolutionManagement {
    maven(url = "https://artifactory.bespot.com/artifactory/bespot-antifraud")
    maven(url = "https://artifactory.bespot.com/artifactory/bespot-logger")
    maven(url = "https://jitpack.io" )
}

The bespot-logger dependency is needed in order to have available logs for our mobile developers to make debugging easier, and the jitpack dependency is needed for some dependencies our SDK has. We will try to remove them at a later date

Next, add the following dependency inside your app's build.gradle.kts file

dependencies {
    implementation("com.bespot.antifraud:sdk-android:$latest_version")
}

Finally, you need to pass the API_KEY and API_URL as resValues inside your app's build.gradle.kts file:

resValue("string", "antifraud_sdk_key", YOUR_API_KEY)
resValue("string", "antifraud_sdk_api_url", YOUR_API_URL)

or via your app's strings.xml file

<string name="antifraud_sdk_key">YOUR_API_KEY</string>
<string name="antifraud_sdk_api_url"> YOUR_API_URL</string>

Usage

The Antifraud SDK requires four permissions:

Our SDK exposes the following methods:

Check

This method performs a single check for fraudulent activities. It should be used when the application need to verify a specific user action, ex. the user clicks a button in your app. The check method uses a FraudulentCheckObserver callback which can be used for handling the Actions returned from our service or possible Failures.

safeSdk.check(object : FraudulentCheckObserver {
    override fun onSuccess(action: Action, signature: String) {
        // Your onSuccess logic
    }

    override fun onError(error: Failure) {
        // Your onError logic
    }
}
)

Subscribe

This method initializes a subscription to the periodic check process which runs in your app every ~5 seconds. You should only really use it if you wish to monitor how the user's device detected fraudulent state changes over time, and not for a user action. The subscribe method uses a FraudulentSessionObserver callback which you can use for handling the Actions returned from our service or possible Failures.

safeSdk.subscribe(object : FraudulentSessionObserver {
    override fun perform(action: Action, signature: String) {
        // Your onSuccess logic
    }

    override fun onError(error: Failure) {
        // Your onError logic
    }
}
)

Unsubscribe

This method cancels the subscription mentioned above.

safeSdk.unsubscribe()

SetUserId

This method sets a String object as the UserId. It is recommended to pass something unique as the UserId

safeSdk.setUserId(id: String)

Logging

This method enables the logs for our service. This should be enabled only in debug builds.

safeSdk.logging(enable: Boolean)

Because the Callbacks used in check and subscribe methods are similar we will merge them at a later date

Failures

When an error occurs, the check and subscribe methods we return the following objects (which you should handle):

when (error) {
    is Failure.NetworkConnection -> // Connection Error
    is Failure.NoActiveApiKey -> // The Api Key is either disabled or wrong
    is Failure.NoChecksAvailableFailure -> // The server did not find available Checks
    is Failure.NoRecipeFoundFailure -> // The application does not have a valid Recipe
    is Failure.NotInitialized -> // The SDK is not initialized
    is Failure.ServerError -> // Remote Server Error
    is Failure.UnknownError -> // Unknown Error (see Support section)
}

Support

We use Github issues to track bugs and enhancements.

  • If you find a bug please fill out an issue report. Provide as much information as possible.
  • If you think of a great idea please fill out an issue as a proposal for your idea.

License

(C) Copyright 2020-2024 Bespot P.C. All rights reserved. See LICENSE for more information. Bespot Location tracking to drive growth, profitability and customer engagement

About

The public release for Antfraud SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages