as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

AmazonDeviceMessagingServer

Constructors

new AmazonDeviceMessagingServer()

new AmazonDeviceMessagingServer(): AmazonDeviceMessagingServer

Returns

AmazonDeviceMessagingServer

Methods

getMajorVersion()

static getMajorVersion(): number

Returns

number


getMinorVersion()

static getMinorVersion(): number

Returns

number


getPatchVersion()

static getPatchVersion(): number

Returns

number


registerAsync()

static registerAsync(): Promise<string>

Register the client app with the ADM cloud, allowing the app to receive ADM messages.

Returns

Promise<string>

A Promise from which the app's registration ID can be retrieved.

Throws

. Default exception with an error message.


registerHandler()

static registerHandler(handler): void

Register a message handler with the AmazonDeviceMessagingServer. This handler will be invoked to handle incoming ADM messages.

@param[in] handler The client app's message handler.

Parameters

handler

AmazonDeviceMessagingHandler

Returns

void


subscribeToTopicAsync()

static subscribeToTopicAsync(topic): Promise<void>

Subscribe the client app to a topic for topic-based messaging. The app will receive ADM messages sent to this topic.

@param[in] topic The topic to subscribe to.

Parameters

topic

string

Returns

Promise<void>

Throws

. Default exception with an error message.

Throws

. If topic name doesn't follow the pattern [a-zA-Z0-9-_.~%]{1,100}


unregisterAsync()

static unregisterAsync(): Promise<string>

Unregister the client app from the ADM cloud. The app will no longer receive ADM messages.

Returns

Promise<string>

A Promise from which the previous (now unregistered) registration ID can be retrieved.

Throws

. Default exception with an error message.


unsubscribeFromTopicAsync()

static unsubscribeFromTopicAsync(topic): Promise<void>

Unsubscribe the client app from a topic for topic-based messaging. The app will stop receiving ADM messages sent to this topic.

@param[in] topic The topic to unsubscribe from.

Parameters

topic

string

Returns

Promise<void>


waitForMessageHandlerCompletionAsync()

static waitForMessageHandlerCompletionAsync(timestamp): Promise<Object>

Method used to wait for the completion of message handling.

@param[in] timestamp. Timestamp in future to wait for message handler to handle message.

Parameters

timestamp

Date

Returns

Promise<Object>


wrapHandleOnMessage()

static wrapHandleOnMessage(handler, message, id): Promise<void>

A wrapper method that waits for the client applications' message handler to handle the ADM message, and resolves/rejects the promise correlated to the message based on the response from the handler.

@param[in] handler. The client application's message handler responsible for handling the incoming message. @param[in] message. An ADM message to be processed by the client application's message handler. @param[in] id. An identifier unique to ADM message, used to mark completion of handling ADM message.

Parameters

handler

AmazonDeviceMessagingHandler

message

AmazonDeviceMessagingMessage

id

number

Returns

Promise<void>

Example

// Example client application's message handler
const handler: AmazonDeviceMessagingHandler = {
  handleOnMessage(message: AmazonDeviceMessagingMessage): Promise<void> {
    // Process the incoming message
    // Return or throw an error based on the message handling
  },
};

// Usage of the wrapper method with the message handler
wrapHandleOnMessage(
  handler,
  { md5: "md5", data: { key: "value" } },
  "messageId",
);

Last updated: Sep 30, 2025