Class: Messangi

Messangi


new Messangi()

Members


<readonly> Priority :number

Enum for Priority values.

Type:
  • number
Properties:
Name Type Default Description
PRIORITY_BALANCED_POWER_ACCURACY number 102

Request "block" level accuracy. Block level accuracy is considered to be about 100 meter accuracy. Using a coarse accuracy such as this often consumes less power.

PRIORITY_HIGH_ACCURACY number 100

Request the most accurate locations available. This will return the finest location available

PRIORITY_LOW_POWER number 104

Request "city" level accuracy. City level accuracy is considered to be about 10km accuracy. Using a coarse accuracy such as this often consumes less power.

PRIORITY_NO_POWER number 105

(Default) Request the best accuracy possible with zero additional power consumption. No locations will be returned unless a different client has requested location updates in which case this request will act as a passive listener to those locations.

Methods


init(success, error)

Initializes the MessangiSDK plugin

Parameters:
Name Type Description
success initCallback

If initialization finishes correctly

error errorCallback

If any error happens in the initialization process

Returns:
Type
void

validUser(success, error)

Verifies if user is registered

Parameters:
Name Type Description
success function

If the function is called correctly

error errorCallback

if any error is caught calling this method

Returns:
Type
void

getUserID(success, error)

Get the User ID registered in Messangi

Parameters:
Name Type Description
success getUserIDCallback

Method to invoke if user is successfully registered with phoneNumber as parameter

error getUserIDErrorCallback

Method to invoke if user is not yet registered

Returns:
Type
void

onPushReceived(success, error)

Set the callback for the Push Received event

Parameters:
Name Type Description
success onPushReceivedCallback

Method to invoke if a push notification arrives

error errorCallback

Method to invoke in case of error

Returns:
Type
void

onLocationUpdate(success, error)

Set the callback for Location Update event

Parameters:
Name Type Description
success onLocationUpdateCallback

Method to invoke when a location update event is fired

error errorCallback

Method to invoke in case of error

Returns:
Type
void

onGeofenceTriggered(success, error)

Set the callback for Geofence Triggered event

Parameters:
Name Type Description
success onGeofenceTriggeredCallback

Method to invoke when a geofence is triggered

error errorCallback

Method to invoke in case of error

Returns:
Type
void

getCurrentLocation(success, error)

Get Current Location

Parameters:
Name Type Description
success getCurrentLocationCallback

Method to invoke when a location update event is fired

error errorCallback

Method to invoke in case of error

Returns:
Type
void

register(success, error [, token])

Show auto registration dialog

Parameters:
Name Type Argument Description
success registerCallback

Method callback if registration is successful

error errorCallback

Method callback if an error has occurred

token string <optional>

If phone number is not provided then a prompt is displayed


registerWithToken(success, error [, token])

Register the User with Token in the Messangi Backend

Parameters:
Name Type Argument Description
success registerWithTokenCallback

Method callback if the registration is successful

error errorCallback

Method callback if an error has occurred

token string <optional>

If phone number is not provided then a prompt is displayed


registerWithPhone(success, error, phone)

First Step in a custom registration process, sends phone number to Messangi Server

Parameters:
Name Type Description
success registerWithPhoneCallback

Method to invoke if the phone user is successfully sent to the Messangi Server

error errorCallback

Method to invoke if an error has occurred

phone string

Phone number to register

Returns:
Type
void

activatePhoneWithCode(success, error, code)

Second step in custom registration process, sends the validation code arrived via SMS to Messangi to validate the user registration

Parameters:
Name Type Description
success activatePhoneWithCodeCallback

Invoked if code validation is successfully sent to Messangi.

error errorCallback

Method to invoke if an error has occurred

code string

The code number arrived via SMS

Returns:
Type
void

getAvailableWorkspaces(success, error)

Lists all Workspaces available to join

Parameters:
Name Type Description
success getAvailableWorkspacesCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

Returns:
Type
void

getSubscribedWorkspaces(success, error)

Lists all Workspaces to which the user is subscribed

Parameters:
Name Type Description
success getSubscribedWorkspacesCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

Returns:
Type
void

getDefaultWorkspace(success, error)

Gets the Default Workspace

Parameters:
Name Type Description
success getDefaultWorkspaceCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

Returns:
Type
void

getWorkspace(success, error, clientId)

Gets a Workspace using ClientID

Parameters:
Name Type Description
success getWorkspaceCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

clientId string

The clientId of workspace to fetch

Returns:
Type
void

joinWorkspace(success, error, clientId)

Joins a new workspace and starts receiving notifications from it

Parameters:
Name Type Description
success joinWorkspaceCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

clientId string

clientId ID of workspace to subscribe

Returns:
Type
void

leaveWorkspace(success, error, clientId)

Removes workspace subscription and stops receiving notifications from it

Parameters:
Name Type Description
success leaveWorkspaceCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

clientId string

clientId ID of the workspace to leave

Returns:
Type
void

sendMessage(success, error, message [, clientId])

Sends a message from device to a workspace

Parameters:
Name Type Argument Description
success sendMessageCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

message string

Text to send to the Workspace

clientId string <optional>

(Optional) Client ID of the workspace to which the message is being sent. By default uses the Main Workspace

Returns:
Type
void

listMessages(success, error [, clientsIds])

Gets all the messages received by the MessangiSDK, filtering them by specific workspaces

Parameters:
Name Type Argument Description
success listMessagesCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

clientsIds Array.<string> <optional>

Array with all workspaces client IDs. By default uses the Main Workspace

Returns:
Type
void

listGeofences(success, error [, clientsIds])

Gets all the Geofences received by the MessangiSDK, filtering them by specific workspaces

Parameters:
Name Type Argument Description
success listGeofencesCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

clientsIds Array.<string> <optional>

Array with all workspaces client IDs. By default uses the Main Workspace

Returns:
Type
void

listBeacons(success, error [, type] [, clientsIds])

Gets all the Beacons received by MessangiSDK, filtering them by specific workspaces

Parameters:
Name Type Argument Description
success listBeaconCallback

Method to invoke after successful execution

error errorCallback

Method to invoke if an error has occurred

type string <optional>

(Optional) string with the type of Beacon to retrieve; available types: "all", "bluetooth" or "wifi"

clientsIds Array.<string> <optional>

(Optional) Array with all workspaces client IDs. By default uses the Main Workspace

Returns:
Type
void

setLocationPriority(priority)

(Only for Android) - Set the priority of the location request, is a strong hint to the LocationClient for which location sources to use.

Parameters:
Name Type Description
priority Priority

An accuracy or power constant

Returns:
Type
void

setLocationInterval(interval)

(Only for Android) - Set the desired interval for active location updates, in milliseconds. This interval is inexact. You may not receive updates at all (if no location sources are available), or you may receive them slower than requested. You may also receive them faster than requested (if other applications are requesting location at a faster interval).

Parameters:
Name Type Description
interval number

Desired interval in millisecond, inexact

Returns:
Type
void

usePowerSaver(enable)

(Ony for Android) - Creating an instance power saver class can improve battery life by 60% by slowing down scans when your app is in the background.

Parameters:
Name Type Description
enable booleam

true if are enable, false otherwise

Returns:
Type
void

useAndroidLScanner(enable)

(Ony for Android) - Allows devices with API 21+ will use the Android L APIs to scan for beacons, below 21 API use old Android Way.

Parameters:
Name Type Description
enable booleam

true if are enable, false otherwise

Returns:
Type
void

useTrackingCache(enable)

(Ony for Android) - Allow the library to use a tracking cache

Parameters:
Name Type Description
enable boolean

true if are enable, false otherwise

Returns:
Type
void

setBeaconExitPeriod(millis)

(Ony for Android) - Elapsed time to check if Exit/Enter event will be triggered

Parameters:
Name Type Description
millis number

Set region exit period in milliseconds


useRegionPersistence(enable)

(Ony for Android) - Turns off saving the state of monitored regions to persistent storage so it is retained over app restarts. Defaults to enabled

Parameters:
Name Type Description
enable boolean

true if are enable, false otherwise


autoSetScanMode(enable)

(Ony for Android) - Enable or not automatically change between Background and Foreground modes. This method require app restart.

Parameters:
Name Type Description
enable

true if are enable, false otherwise


useBackgroundScanMode()

(Ony for Android) - This method notifies the beacon service that the application is either moving to background mode.


useForegroundScanMode()

(Ony for Android) - This method notifies the beacon service that the application is either moving to foreground mode.


setForegroundScanCycles(scanPeriod, sleepPeriod)

(Ony for Android) - Set the duration in milliseconds of each Foreground Cycle

Parameters:
Name Type Description
scanPeriod

Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons.

sleepPeriod

Sets the duration in milliseconds between each Bluetooth LE scan cycle to look for beacons.


setBackgroundScanCycles(scanPeriod, sleepPeriod)

(Ony for Android) - Set the duration in milliseconds of each Background Cycle

Parameters:
Name Type Description
scanPeriod

Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons.

sleepPeriod

Sets the duration in milliseconds between each Bluetooth LE scan cycle to look for beacons.