SiftAndroidPrivate

Sift Android Beta

License

License

Categories

Categories

Science Business Logic Libraries
GroupId

GroupId

com.siftscience
ArtifactId

ArtifactId

sift-android-private
Last Version

Last Version

0.9.11
Release Date

Release Date

Type

Type

aar
Description

Description

SiftAndroidPrivate
Sift Android Beta
Project URL

Project URL

https://github.com/SiftScience/sift-android
Source Code Management

Source Code Management

https://github.com/SiftScience/sift-android

Download sift-android-private

How to add to project

<!-- https://jarcasting.com/artifacts/com.siftscience/sift-android-private/ -->
<dependency>
    <groupId>com.siftscience</groupId>
    <artifactId>sift-android-private</artifactId>
    <version>0.9.11</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.siftscience/sift-android-private/
implementation 'com.siftscience:sift-android-private:0.9.11'
// https://jarcasting.com/artifacts/com.siftscience/sift-android-private/
implementation ("com.siftscience:sift-android-private:0.9.11")
'com.siftscience:sift-android-private:aar:0.9.11'
<dependency org="com.siftscience" name="sift-android-private" rev="0.9.11">
  <artifact name="sift-android-private" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.siftscience', module='sift-android-private', version='0.9.11')
)
libraryDependencies += "com.siftscience" % "sift-android-private" % "0.9.11"
[com.siftscience/sift-android-private "0.9.11"]

Dependencies

compile (5)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.8.2
javax.annotation : javax.annotation-api jar 1.2
com.squareup.okhttp3 : okhttp jar 3.4.1
org.apache.commons : commons-lang3 jar 3.5
com.google.android.gms » play-services-location jar 9.8.0

Project Modules

There are no modules declared in this project.

Sift Android SDK

Introduction

The Sift Android SDK collects and sends Android device information and application interaction events to Sift for use in improving fraud detection accuracy.

Installing Sift

Add Sift to your application’s build.gradle file:

dependencies {
  ...
  compile 'com.siftscience:sift-android:0.11.1'
  ...
}

You may also need to add the following packagingOptions to the main android block:

android {
  ...
  packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
  }
  ...
}

Integrating Sift

There are two different integration paths to take for incorporating Sift into your application. The first one will be detailed below in the Application Integration section. Follow these instructions if your application flow is primarily based on Activities. If your application flow is based on a combination of Activities and Fragments, please refer to the the Custom Integration section.

Application Integration

Add Sift to your Application file

Create an Application file if you haven’t already. Create an internal class that implements the ActivityLifecycleCallbacks interface and register Sift as shown below:

import siftscience.android.Sift;

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacksHandler());
    }

    private static final class ActivityLifecycleCallbacksHandler
            implements ActivityLifecycleCallbacks {
        public void onActivityCreated(Activity activity, Bundle bundle) {
            Sift.open(activity, new Sift.Config.Builder()
                .withAccountId("YOUR_ACCOUNT_ID")
                .withBeaconKey("YOUR_BEACON_KEY")
                // Uncomment to disallow location collection
                // .withDisallowLocationCollection(true)
                .build());
            Sift.collect();
        }
        public void onActivityPaused(Activity activity) {
            Sift.pause();
        }
        public void onActivityResumed(Activity activity) {
            Sift.resume(activity);
        }
        public void onActivityDestroyed(Activity activity) {
            Sift.close();
        }
    }
}

Set the user id

As soon as your application is aware of the user id, set it on the Sift instance using the code below. All subsequent events will include the user id.

Sift.setUserId("SOME_USER_ID");

If the user logs out of your application, you should unset the user id:

Sift.unsetUserId();

Custom Integration

Initialize Sift in your main Activity

Configure the Sift object in the onCreate method of your application's main Activity (the one that begins the application). If the user id is known at this point, you can set it here. Otherwise, you should set it as soon as it is known. In the main Activity, also override onPause, onResume, and onDestroy as shown:

import siftscience.android.Sift;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hello_sift);
        Sift.open(this, new Sift.Config.Builder()
            .withAccountId("YOUR_ACCOUNT_ID")
            .withBeaconKey("YOUR_BEACON_KEY")
            // Uncomment to disallow location collection
            // .withDisallowLocationCollection(true)
            .build());
        Sift.collect();
    }
    @Override
    protected void onPause() {
        super.onPause();
        Sift.pause();
    }
    @Override
    protected void onResume() {
        super.onResume();
        Sift.resume(this);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Sift.close();
    }
}

Add Sift to your application flow

For each Activity or Fragment that represents a unique page in your application flow, override onStart, onPause, onResume, and onDestroy:

public class OtherActivity extends AppCompatActivity {
    @Override
    protected void onStart(Bundle savedInstanceState) {
        super.onStart();
        Sift.open(this);
        // For Fragments, use Sift.open(this.getActivity()) instead
        Sift.collect();
    }
    @Override
    protected void onPause() {
        super.onPause();
        Sift.save();
    }
    @Override
    protected void onResume() {
        super.onResume();
        Sift.resume(this);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Sift.close();
    }
}

Set the user id

As soon as your application is aware of the user id, set it on the Sift instance using the code below. All subsequent events will include the user id.

Sift.setUserId("SOME_USER_ID");

If the user logs out of your application, you should unset the user id:

Sift.unsetUserId();
com.siftscience

Sift

At Sift (formerly Sift Science), we're building the world’s leading Digital Trust & Safety platform.

Versions

Version
0.9.11
0.0.4
0.0.3
0.0.2
0.0.1