目录

CLASS info
public abstract class MessageEngine
Defines a set of APIs to publish or subscribe to messages between nearby devices. Unless the PendingIntent parameter is passed when #Get is called, all of the APIs need to be used from a foreground activity. You need to symmetrically call put or unput, get or unget, and onStart or onStop.

Public Method Summary

ReturnMethod
voidhandleIntent(Intent intent, MessageHandler handler)
Extracts information from an intent in subscription callback, and calls the corresponding methods on the specified MessageHandler. Currently, only onFound and onLost are supported.
Task<Void>put(Message message)
Publishes a message and broadcasts a sharing code for nearby devices to scan.
Task<Void>put(Message message, PutOption options)
Publishes a message and broadcasts a sharing code for nearby devices to scan.
Task<Void>registerStatusCallback(StatusCallback statusCallback)
Registers a status callback function, which will notify your app of key events.
Task<Void>get(MessageHandler handler, GetOption options)
Subscribes to messages published by a nearby device.
Task<Void>get(MessageHandler handler)
Registers the messages to be obtained with the cloud using the default option (DEFAULT).
Task<Void>get(PendingIntent pendingIntent, GetOption options)
This method identifies only BLE beacon messages.
Task<Void>get(PendingIntent pendingIntent)
This method identifies only BLE beacon messages.It subscribes to messages published by nearby devices in a persistent and low-power manner and uses the default configuration (DEFAULT).
Task<Void>unput(Message message)
Cancels message publishing.
Task<Void>unregisterStatusCallback(StatusCallback statusCallback)
Cancels the status callback registered before.
Task<Void>unget(MessageHandler handler)
Cancels a message subscription.
Task<Void>unget(PendingIntent pendingIntent)
Cancels a message subscription.

Public Methods

Method
public abstract void handleIntent(Intent intent, MessageHandler handler)
Extracts information from an intent in subscription callback, and calls the corresponding methods on the specified MessageHandler. Currently, only onFound and onLost are supported.

Parameters

Parameter nameParameter desc
intentIntent content.
handlerMessage callback processing.
Method
public abstract Task<Void> put (Message message)
Publishes a message and broadcasts a token for nearby devices to scan.

Parameters

Parameter nameParameter desc
messagePublished message.
Method
public abstract Task<Void> put(Message message, PutOption options)
Publishes a message and broadcasts a token for nearby devices to scan. This message is published only to apps that use the same project ID and have registered the message type with the cloud for subscription.

Parameters

Parameter nameParameter desc
messagePublished message.
optionsPutOption parameters.
Method
public abstract Task<Void> registerStatusCallback(StatusCallback statusCallback)
Registers a status callback function, which will notify your app of key events. When your app calls one of the APIs for the first time, the function will return the status.

Parameters

Parameter nameParameter desc
statusCallbackstatusCallback function.
Method
public abstract Task<Void> get(MessageHandler handler, GetOption options)
Registers the messages to be obtained with the cloud. Only messages with the same project ID can be obtained.

Parameters

Parameter nameParameter desc
handlerMessageHandler implementation to obtain callbacks of received messages.
optionsGetOption parameters.
Method
public abstract Task<Void> get(MessageHandler handler)
Registers the messages to be obtained with the cloud using the default option (DEFAULT).

Parameters

Parameter nameParameter desc
handlerMessageHandler implementation to obtain callbacks of received messages.
Method
public abstract Task<Void> get(PendingIntent pendingIntent, GetOption options)
This method identifies only BLE beacon messages.

Parameters

Parameter nameParameter desc
pendingIntentpendingIntent to obtain callbacks of nearby messages
optionsGetOption parameters.
Method
public abstract Task<Void> get(PendingIntent pendingIntent)
This method identifies only BLE beacon messages. It subscribes to messages published by nearby devices in a persistent and low-power manner and uses the default configuration (DEFAULT).

Parameters

Parameter nameParameter desc
pendingIntentpendingIntent to obtain callbacks of nearby messages
Method
public abstract Task<Void> unput(Message message)
Cancels message publishing.

Parameters

Parameter nameParameter desc
messagePublished message.
Method
public abstract Task<Void> unregisterStatusCallback(StatusCallback statusCallback)
Cancels the status callback registered before.

Parameters

Parameter nameParameter desc
statusCallbackStatus callback registered before.
Method
public abstract Task<Void> unget(MessageHandler handler)
Cancels a message subscription.

Parameters

Parameter nameParameter desc
handlerMessage handler registered before.
Method
public abstract Task<Void> unget(PendingIntent pendingIntent)
Cancels a message subscription.

Parameters

Parameter nameParameter desc
pendingIntentPending intent registered before.