Android

Migrating from Fraudmetrix to TDMobRisk

With the upgrade of the company's brand, we have made some changes to the API in the SDK. This guide compares the access methods of the new and old versions of the SDK and is used as a guide for customers to migrate from the old version of SDK Fraudmetrix to the new version of SDK TDMobRisk.

Integration changes

New version (TDMobRisk)

Use Maven Center to rely on integration. Before integration, you must delete fraudmetrix-xxx.aar in the project libs file. Then add dependencies to the app/build.gradle of the project, as follows:

dependencies {
     // device fingerprint
     implementation 'com.trustdecision.android:mobrisk:x.x.x.x'
  }

Old version (Fraudmetrix)

You need to contact the relevant operation colleagues to download the fraudmetrix-xxx.aar file for integration.

Naming Changes

Some class names in the SDK are renamed

  • Entry class FMAgent renamed to TDRisk
  • Configuration class TDOption renamed to TDRiskOption
  • Callback method FMCallback renamed to TDRiskCallback

SDK initialization

When the application starts, for example, in the application's onCreate method (Android 6.0 and above versions should ensure that the permission has been applied) call the following method:

Method 1 (recommended method)

New Version (TDMobRisk)

The code example is as follows:

TDRisk.Builder builder = new TDRisk.Builder()
         .appKey(appKey) //appkey needs to be provided by the operator
         .partnerCode(partner) //Partner partners need to provide
         .appName(appName) //appName needs to be provided by the operator
         .country(TDRisk.COUNTRY_CN) // Country parameters, such as cn, sg, us, fra
TDRisk.initWithOptions(this, builder);

Get blackbox when your business needs it

String blackbox = TDRisk. getBlackBox();

⚠️Note: You must ensure that initWithOptions is called before getBlackBox!

Old Version (Fraudmetrix)

The code example is as follows:

FMAgent.Builder builder = new FMAgent.Builder()
         .appKey(appKey) //appkey needs to be provided by the operator
         .production(true) //true: production environment; false: sandbox environment
         .partner(partner) //partner partners need to provide
         // Configure the site collection address through url(), please replace the "collection address" in the code according to the site
         // China: No need to configure url
         // North America: https://usfp.tongdun.net
         // Singapore: https://sg-fp.apitd.net
         // Germany: https://frafp.tongdun.net
         // Indonesia: https://idfp.tongdun.net
         .url("collection address/android3_8/profile.json")
         .build();
FMAgent.init(this, builder);

Get blackbox when your business needs it

String blackbox = FMAgent.onEvent(context);

Method 2

New Version (TDMobRisk)

The code example is as follows:

TDRisk.Builder builder = new TDRisk.Builder()
         .appKey(appKey) //appkey needs to be provided by the operator
         .partnerCode(partner) //Partner partners need to provide
         .appName(appName) //appName needs to be provided by the operator
         .country(TDRisk.COUNTRY_CN) // Country parameters, such as cn, sg, us, fra
         .callback(new TDRiskCallback() {
             @Override
             public void onEvent(String blackbox) {
                 // Here the callback is in the child thread
                 // When the network is normal, the result will be returned within 200-300ms.
                 // When the network is abnormal, it will return after a timeout (up to 15s by default).
                 // Please add your processing logic for blackbox below
                 Log.i("TDRiskDemo", "blackbox: " + blackbox);
             }
         });
TDRisk.initWithOptions(this, builder);

Old Version (Fraudmetrix)

The code example is as follows:

TDOption option = new FMAgent.Builder()
        .production(true) //true: production environment; false: sandbox environment
        .partner(partner) //partner partners need to provide
        // Configure the site collection address through url(), please replace the "collection address" in the code according to the site
        // China: No need to configure url
        // North America: https://usfp.tongdun.net
        // Singapore: https://sg-fp.apitd.net
        // Germany: https://frafp.tongdun.net
        // Indonesia: https://idfp.tongdun.net
        .url("collection address/android3_8/profile.json")
        .callback(new FMCallback() {
            @Override
            public void onEvent(String blackbox) {
                // Note that this is not the main thread, please do not perform ui operations in this function, otherwise a crash may occur
                mBlackBox = blackbox;
            }
        })
        .build();
FMAgent.init(this, option);

FMAgent.ENV_SANDBOX indicates the test environment and FMAgent.ENV_PRODUCTION indicates the production environment.

The difference between the two methods

  • TUIhe fithe result will be returned within 200-300ms when the network is normalrst method is to obtain the blackbox synchronously. If you call getBlackBox on the main thread, you need to pay attention to the time-consuming problem.
  • The second method is to obtain the blackbox asynchronously. It should be noted that the callback result is not in the main thread, and it is forbidden to operate the UI in the callback.

Integration result verification

Successful initialization will print the following log in logcat:

TD_JAVA: Tongdun sdk load success
TD_JAVA: Tongdun sdk init success

⚠️ If there is no above log, please find Call init in the logcat, and modify your integration method according to the error message.

⚠️Verify whether the integration is successful, you can uninstall and reinstall (to avoid cache impact), and call the SDK to check the returned blackbox, if it is a 26-length string, the integration is successful. If the returned blackbox is longer, it means that there is a problem in the integration process, and the SDK development engineer needs to assist and confirm.