Skip to content

Adnuntius Data

Jason Pell edited this page Jan 25, 2022 · 2 revisions

A new DataClient is available to generate sync, profile update (aka visitor) and page events to adnuntius data.

Refer to https://docs.adnuntius.com/adnuntius-data/api-documentation/http

import com.adnuntius.android.sdk.data.DataClient;

...

final DataClient dataClient = new DataClient(getApplicationContext());

Sync Profile

final Sync sync = new Sync();
sync.setFolderId("000000000000009d");
sync.setBrowserId("some browser id");
sync.setExternalSystemIdentifier("SOME CRM SYSTEM", "some user id in crm SOME CRM SYSTEM");

dataClient.sync(sync, new DataResponseHandler() {
    @Override
    public void onSuccess() {
        // do something on success if necessary
    }

    @Override
    public void onFailure(ErrorResponse response) {
        // on failure, do something here
    }
});

Profile Update

Date and Timestamp API 25 gotchas

If your application minSdkVersion is at least 26, you can use the setters which accept java.time.LocalDate or java.time.Instant.

If your application minSdkVersion is before 26, you can use the setters which accept com.adnuntius.android.sdk.data.profile.LocalDate or com.adnuntius.android.sdk.data.profile.Instant compatibility classes.

final Profile profile = new Profile();
profile.setFolderId("some folder id");
profile.setBrowserId("some browser id");
profile.setExternalSystemIdentifier("SOME CRM SYSTEM", "some user id in crm SOME CRM SYSTEM");
profile.setProfileValue(ProfileFields.company, "Adnuntius");
profile.setProfileValue(ProfileFields.country, "Norway");
profile.setProfileValue(ProfileFields.dateOfBirth, LocalDate.of(1994, 2, 14));
profile.setProfileValue(ProfileFields.createdAt, Instant.now());

dataClient.profile(profile, new DataResponseHandler() {
    @Override
    public void onSuccess() {
        // do something on success if necessary
    }

    @Override
    public void onFailure(ErrorResponse response) {
        // on failure, do something here
    }
});

Page View

If you use the constructor which accepts a page url, the domainName and url path categories will be derived. If you want to handle this yourself, use the setDomainName and addCategories methods directly.

final Page page = new Page("the page url");
page.setBrowserId("some browser id");
page.setFolderId("some folder id");
page.addCategories("minecraft", "doom");
page.addKeywords("wood", "plastic");
dataClient.page(page, new DataResponseHandler() {
    @Override
    public void onSuccess() {
        // do something on success if necessary
    }

    @Override
    public void onFailure(ErrorResponse response) {
        // on failure, do something here
    }
});

Examples

An example app is available here: https://github.com/Adnuntius/android_sdk_examples

Clone this wiki locally