User

Get Information

The UserInfo object contains many useful information about the user, like push token, appInstall (identifies the current installation), userId (identifies the current kiwi user), androidId, advertisingId, and so on.

Recover locally

UserInfo userInfo = kiwiSDK.user().retrieveLocalInformation().get();
String pushToken = userInfo.getPushToken(); // push token obtained example

Recover remotelly

kiwiSDK.user().fetchInformation(new FetchInformationListener() {
            @Override
            public void onSuccess(UserInfo userInfo) {
                String appVersion = userInfo.getAppVersion();
                String advertisingId = userInfo.getAdvertisingId();
            }

            @Override
            public void onError() {
                // handle error
            }
        });

NOTE: This operation will be performed on background.

Scenario

This feature turns possible the app use different parameters for each scenario. The scenario is sorted automacally by Kiwi backend, but if the scenario was not assigned for the current installation yet, and you need to use, you can use the embedded scenario.

To check if the scenario was already assigned, do the following:

if (!kiwiSDK.user().hasScenario()) {
    kiwiSDK.user().useEmbeddedScenario(EMBEDDED_SCENARIO_ID, R.raw.scenario);
}

// use the scenario
// ...

The R.raw.scenario is a raw json that represents the embedded scenario. You must download the json on Kiwi Manager, after creates your scenario, and get your scenarioId too.

Recover locally

    Scenario scenario = kiwiSDK.user().retrieveLocalScenario("pt").get();

Recover remotelly

    kiwiSDK.user().fetchScenario("pt", new FetchScenarioListener() {
            @Override
            public void onSuccess(Scenario scenario) {

            }

            @Override
            public void onError() {
                // handle error
            }
        });

NOTE: This operation will be performed on background.

Private Settings

The private settings are special properties that are stored on kiwi backend and are shared only for user installations of the same Kiwi Application.

Using the Private Settings

    PrivateSettings privateSettings = kiwiSDK.user().retrieveLocalPrivateSettings("default").get();
    privateSettings.put("tutorial", "done");
    privateSettings.put("facebookId", "12435tsx354t6sbgg7");
    privateSettings.saveInBackground();

NOTE: the operation saveInBackground will be performed in background.

Recover locally

    PrivateSettings privateSettings = kiwiSDK.user().retrieveLocalPrivateSettings("default").get();

Recover remotelly

    kiwiSDK.user().fetchPrivateSettings("default", new FetchPrivateSettingsListener() {
            @Override
            public void onSuccess(PrivateSettings privateSettings) {

            }

            @Override
            public void onError() {
                // handle error
            }
        });

NOTE: This operation will be performed on background.

Shared Settings

The shared settings are special properties that are stored on kiwi backend and are shared between all user installations of any Kiwi Application of the same product (the current product).

Using the Shared Settings

    SharedSettings sharedSettings = kiwiSDK.user().retrieveLocalSharedSettings("default").get();
    sharedSettings.put("choosedWallpaperId", "12");
    sharedSettings.saveInBackground();

NOTE: the operation saveInBackground will be performed in background.

Recover locally

    SharedSettings sharedSettings = kiwiSDK.user().retrieveLocalSharedSettings("default").get();

Recover remotelly

    kiwiSDK.user().fetchSharedSettings("default", new FetchSharedSettingsListener() {
            @Override
            public void onSuccess(SharedSettings privateSettings) {

            }

            @Override
            public void onError() {
                // handle error
            }
        });

NOTE: This operation will be performed on background.

Tags

You can tag that current installation. The tags can be used for push notifications after.

   Set<String> tags = new HashSet<String>();
   tags.add("tag_1");
   tags.add("tag_2");
   kiwiSDK.user().updateTags(tags);

NOTE: This operation will be performed on background.

Check installation

You can check if the user was installed on kiwi backend:

   boolean isInstalled = kiwiSDK.user().isInstalled();

Last updated