Mobile SDK

Shared Instance

Overview

Use this method to access the main object with which you can access to all the API functionality.

Signature

public static Messangi getInstance();

Usage

Messangi.getInstance()

Returns

This method returns the shared instance of the Messangi's object.

Init Messangi

Overview

One of the first init steps, this method will start our internal service for PUSH notifications.

Signature

public void init(Context context);

Parameters

Parameter Name Description Possible Values
context Parent context on the host App Context

Usage

Messangi.getInstance().init(<context>);

Message Listener

Overview

The host app have to implement the MessangiListener interface in its main Activity, by doing this the host app enables the reception of PUSH notifications (GeoFences, Beacons, Messages, etc)

After the implementation has taken place you need to pass the Listener Activity to Messangi SDK using this method.

Signature

public void addMessangiListener(MessangiListener listener);

Parameters

Parameter Name Description Possible Values
listener Activity attending incoming messages (must implement the MessangiListener interface) MessangiListener

Usage

Messangi.getInstance().addMessangiListener(<listener>);

Mobile Registration Dialog

Overview

Launch the default dialog to register the user mobile number with the Messangi SDK, this is optional, host app could implement his own dialog to meet their specific L&F requirements.

Signature

public void registerDialog(Context context, Activity activity);

Parameters

Parameter Name Description Possible Values
context Context to store internal parameters about the registration process Context
activity Parent activity to the registration dialog Activity

Usage

Messangi.getInstance().registerDialog(<context>, <activity>);

Messangi Service

Overview

The host app could request the internal Messangi Service to extend functionality if needed. For example, the Messangi Service grants access to subscribe/unsubscribe to/from distribution lists, manage your inbox or list your fences and beacons.

Usage

We recommend if you are interested on using the Messangi Service to add the following calls into the Activity lifecycle onStart, onResume & onPause as follows:

    @Override
    protected void onStart() {
        super.onStart();
        Messangi.getInstance().init(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Messangi.getInstance().bindService();
    }

    @Override
    protected void onPause() {
        Messangi.getInstance().unBindService();
        super.onPause();
    }

Set Location Type

Overview

This method sets the priority of the location request, this configuration will affect the battery consumption, form Google LocationRequest API:

**PRIORITY_BALANCED_POWER_ACCURACY** - Use this setting to request location precision to within a city block, which is an accuracy of approximately 100 meters. This is considered a coarse level of accuracy, and is likely to consume less power. With this setting, the location services are likely to use WiFi and cell tower positioning. Note, however, that the choice of location provider depends on many other factors, such as which sources are available.

**PRIORITY_HIGH_ACCURACY** - Use this setting to request the most precise location possible. With this setting, the location services are more likely to use GPS (Global Positioning System) to determine the location.

**PRIORITY_LOW_POWER** - Use this setting to request city-level precision, which is an accuracy of approximately 10 kilometers. This is considered a coarse level of accuracy, and is likely to consume less power.

**PRIORITY_NO_POWER** - Use this setting if you need negligible impact on power consumption, but want to receive location updates when available. With this setting, your app does not trigger any location updates, but receives locations triggered by other apps.

You can omit calling this method if you want and PRIORITY_NO_POWER will be used as default

Signature

public void setLocationType(int type)

Usage

Messangi.getInstance().setLocationType(LocationRequest.PRIORITY_HIGH_ACCURACY);

Set Location Update Time

Overview

Use this method to indicate the frequency rate to update the device location, the default value is 10000ms (10 seg)

Signature

public void setLocationUpdateTime(long updateTime);

Parameters

Parameter Name Description Possible Values
updateTime Time in millis to update the device location Number

Usage

Messangi.getInstance().setLocationUpdateTime(<frequency ms>);

Log Event

Overview

Log events with Messangi SDK, they will be available to review later in our Kibana

Signature

public void logEvent(final Context context, final String eventType, final String extraInfo, final String campaignName);

Parameters

Parameter Name Description Possible Values
context Context to store/read internal parameters by Messangi SDK Context
eventType A tag string to represent the event you want to track later at the report tool Text
extraInfo Additional information to add in this record Text
campaignName The campaign name related to this event, could be null Text

Usage

Messangi.getInstance().logEvent(<context>, <eventType>, <extraInfo>, <campaignName/Title>);