Interface IAmazonDeviceMessagingServerAsync
interface IAmazonDeviceMessagingServerAsync
Extends com.amazon.apmf.IStandard
Interface for AmazonDeviceMessaging server.
Methods
registerAsync()
Register the client app with the ADM cloud, allowing the app to receive ADM messages. When invoked for an app with an existing registrationId or while another registerAsync request is in progress, Promise.getValue will return a cached/same registrationId, provided application metadata hasn’t changed. Requires com.amazon.device-messaging.privilege.access privilegeIRegistrationIdPromise*registerAsync()
Returns
IRegistrationIdPromise*
Promise from which the app’s registration ID can be retrieved.
Throws
SecurityError— if the client app does not declare the required privilege
unregisterAsync()
Unregister the client app from the ADM cloud. The app will no longer receive ADM messages. When invoked for an app with no active registrationId (previously unregistered or yet to be registered) Promise.getValue will return a null. Requires com.amazon.device-messaging.privilege.access privilegeIRegistrationIdPromise*unregisterAsync()
Returns
IRegistrationIdPromise*
A Promise from which the previous (now unregistered) registration
ID can be retrieved.
Throws
SecurityError— if the client app does not declare the required privilege
subscribeToTopicAsync()
Subscribe the client app to a topic for topic-based messaging. The app will receive ADM messages sent to this topic. Requires com.amazon.device-messaging.privilege.access privilegeITopicSubscriptionPromise*subscribeToTopicAsync(stringtopic)
Parameters
topic
string — Required
The topic to subscribe to.
Returns
ITopicSubscriptionPromise*
A Promise indicating the success or failure of the subscription
request. There is no value returned through the Promise.
Throws
InvalidArgumentError— If topic name doesn’t follow the pattern[a-zA-Z0-9-_.~%]{1,100}SecurityError— if the client app does not declare the required privilege
unsubscribeFromTopicAsync()
Unsubscribe the client app from a topic for topic-based messaging. The app will stop receiving ADM messages sent to this topic. Requires com.amazon.device-messaging.privilege.access privilegeITopicSubscriptionPromise*unsubscribeFromTopicAsync(stringtopic)
Parameters
topic
string — Required
The topic to unsubscribe from.
Returns
ITopicSubscriptionPromise*
A Promise indicating the success or failure of the unsubscription
request. There is no value returned through the Promise.
Throws
InvalidArgumentError— If topic name doesn’t follow the pattern[a-zA-Z0-9-_.~%]{1,100}SecurityError— if the client app does not declare the required privilege
registerHandler()
Register a message handler with the AmazonDeviceMessagingServer. This handler will be invoked to handle incoming ADM messages.voidregisterHandler(IAmazonDeviceMessagingHandlerAsync*handler)
Parameters
handler
IAmazonDeviceMessagingHandlerAsync* — Required
The client app’s message handler.
Throws
NullPointerError— if message handle passed is null.
waitForMessageHandlerCompletionAsync()
Wait for the registered MessageHandler to finish handling a message.IHandlerCompletionPromise*waitForMessageHandlerCompletionAsync(com.amazon.apmf.MonotonicDurationwaitDuration)
Parameters
waitDuration
com.amazon.apmf.MonotonicDuration — Required
Maximum time to wait, as a duration in seconds and
nanoseconds.
Returns
IHandlerCompletionPromise*
An IHandlerCompletionPromise indicating the status of the message
handler. There is no value returned through the promise.
Throws
InvalidArgumentError— If waitDuration is zero.

