Checking for Manual ReachOut Messages of Any Type

The checkForReachOut() function explicitly checks for manual ReachOut messages on the Server. checkForReachOut() will check for any manual ReachOut message type, whereas checkForReachOutOfType() will check for ReachOut messages of a specified type.

Note:MultableInt and MutableObject are from org.apache.commons.lang.mutable.

checkForReachOut() can be called between startSDK() and stopSDK(), and can be called zero or more times.

checkForReachOut() is a synchronous function, returning when all functionality is completed.

checkForReachOut()

RUIResult checkForReachOut(MutableObject<String> message, MutableInt messageCount, MutableObject<RUIMessageType> messageType)

Parameters

The checkForReachOut() function has the following parameters.

checkForReachOut() Parameters

Parameter

Description

message (MutableObject<String>)

A string of maximum length 256 that will be filled-in by the SDK with the message that is sent by the server.

messageCount (MutableInt)

Receives the message count (including returned message).

messageType (MutableObject<RUIMessageType>)

Receives the type of returned message. Can be either RUIMessageType.TEXT or RUIMessageType.URL.

Returns

The checkForReachOut() function returns one of the return status constants below.

checkForReachOut() Returns

Return

Description

OK

Function successful.

SDK_INTERNAL_ERROR_FATAL

Irrecoverable internal fatal error. No further API calls should be made.

SDK_ABORTED

A required New Registration has failed, and hence the SDK is aborted. stopSDK() is possible.

SDK_SUSPENDED

The Server has instructed a temporary back-off.

SDK_NOT_STARTED

SDK has not been successfully started.

SDK_PERMANENTLY_DISABLED

The Server has instructed a permanent disable.

SDK_OPTED_OUT

Instance has been instructed by the application to opt-out.

CONFIG_NOT_CREATED

Configuration has not been successfully created.

SDK_ALREADY_STOPPED

SDK has already been successfully stopped.

TIME_THRESHOLD_NOT_REACHED

The API call frequency threshold (set by the Server) has not been reached.

NETWORK_CONNECTION_ERROR

Not able to reach the Server.

NETWORK_SERVER_ERROR

Error while communicating with the Server.

NETWORK_RESPONSE_INVALID

Message format error while communicating with the Server.

Code Example

The the following is an example to get all of the messages on the server, check if it is a text or URL message and display the appropriate message box.

// Create instance

boolean registerDefaultReachOut = false;  // No default ReachOut

RUISDK mySDK = new SDKImpl(registerDefaultReachOut);

// Other initialization including application specific ReachOut handler

 

MutableObject<String> message = new MutableObject<>("");

MutableObject<RUIMessageType> msgType = new MutableObject<>(RUIMessageType.ANY);

MutableInt msgCount = new MutableInt(0);

 

while (mySDK.checkForReachOut(message, msgCount, msgType) == RUIResult.OK &&

       msgCount > 0) {

                MutableObject<RUIMessageType> textMsg = new MutableObject<>(RUIMessageType.TEXT);

                MutableObject<RUIMessageTYpe> urlMsg = new MutableObject<>(RUIMessageType.URL);

    if (msgType.equals(testMsg)) {

        //  code to display Text message

    } else if (msgType.equals(urlMsg)){

        // code to display URL

    }

}