Ask or search…
K
Links
Comment on page

AddressCheck (Deprecated)

SDK size

A maximum of about 500 KB, which can decrease because of these elements.

Analytics

Our SDKs by default collect information about the user and running environment to better map fraudsters and understand their behaviors. We recommend keeping this collection active as the only purpose of this data is for fraud reduction, but if you wish, you can disable it by .setAnalyticsSettings(boolean useAnalytics) parameter.

Runtime Permissions

Permission
Reason
Required
ACCESS_BACKGROUND_LOCATION
To check in the background if the user lives where he/she informed
Yes
Some cell phone manufacturers, such as Xiaomi and Oppo, block apps from running in the background unless the user explicitly allows this setting, known as AUTOSTART. For more information, see here.

Starting the SDK

Inside the onCreate method in your Application class, insert:
import com.combateafraude.addresscheck.external.AddressCheck;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
//Inicializa o SDK
AddressCheck.init(this);
}
}
For instructions on how to create your own implementation of the Application class, check the official Android documentation

Instantiating the SDK

First create an object of type AddressCheck. This object is for you to configure all your business rules for the address check:
AddressCheck mAddressCheck = new AddressCheck.Builder(String mobileToken)
// see table below
.build();

Builder method

Parameter
Required
Usage token associated with your CAF account.
Yes
.setPeopleId(String peopleId)
Identifier of the user whose address is being validated.
Yes.
.setAnalyticsSettings(boolean useAnalytics)
Enables/disables data collection for analytics.
No, the default is true
.setNetworkSettings(int requestTimeout)
Sets the timeout interval for SDK requests.
No. The default is 60 (seconds)
With this object created, and after collecting the address entered by the user, create an AddressCollection object passing the AddressCheck object created earlier and assign the address, see example:
AddressCollection mAddressCollection = new AddressCollection(addressCheck, context);
mAddressCollection.setAddress(Address userAddress, new AddressCollection.Callback() {
@Override
public void onSuccess(String userId) {
// the address has been successfully assigned and the userId will be used to check the current status of the verification
}
@Override
public void onFailure(SDKFailure sdkFailure) {
// there was some failure when linking the address
}
});

Address

The Address userAddress object, first parameter of the setAddress() method, is from the android.location.Address class. In it, you must pass the following fields:
Address address = new Address(Locale locale);
address.setCountryName(COUNTRY_NAME);
address.setCountryCode(COUNTRY_CODE);
address.setAdminArea(ADMIN_AREA);
address.setSubAdminArea(SUB_ADMIN_AREA);
address.setLocality(LOCALITY);
address.setSubLocality(SUB_LOCALITY);
address.setThoroughfare(THOROUGHFARE);
address.setSubThoroughfare(SUB_THOROUGHFARE);
address.setPostalCode(POSTAL_CODE);
Method
Example
.setCountryName()
Country Name.
"Brasil"
.setCountryCode()
Country code.
"BR"
.setAdminArea()
State.
"Rio Grande do Sul"
.setSubAdminArea()
State Region.
"Porto Alegre"
.setLocality()
City.
"Porto Alegre"
.setSubLocality()
Neighborhood.
"Azenha"
.setThoroughfare()
Street/Avenue.
"Av. Azenha"
.setSubThoroughfare()
Number.
"200"
.setPostalCode()
Postal Code.
"51110-100"
That's it! After that, our SDK is already evaluating your user's location in the background to verify that he actually lives at the address you entered.

Linking and unlinking the user

In addition to the common flow mentioned above, we also offer methods to bind and unbind a device from an address verification. For example, if a user who already has his address registered logs into his account, in your app, call the method below passing the userId returned by our address verification start method.
AddressCollection.setUserId(String userId, Context context)
With this, the respective device again collects location information to verify the address, if it has not already been verified.
Analogously, there is a method that unlinks the device to an address validation, which can be used in case of an application logout:
AddressCollection.clearUserId(Context context)

Checking the Address Validation Status

To check the status of the address validation, use the following route:
Method: GET

Response

Status: 200 (OK)

Body

Field
Type
Required?
Description
last_activity_ts
number
Yes
Timestamp of the last update.
installations
object
No
Device(s) where this user ID was used.
address_verification
object
No
Verification of address(es).
Last modified 5mo ago