- Send messages to Amazon devices that are running your app
- Deliver messages from your cloud service to apps installed on Amazon devices
Get started
Setup
- Add the following library dependencies to the
dependenciessection of your package.json file.
- To access ADM, add the following privilege and services in your manifest.toml.
Usage
To use the Amazon Device Messaging service, you must:- Declare your components and processes in your manifest.toml file.
- Register your app with the service in your App.ts file.
- Add code to handle task execution.
- Add code to register and handle the ADM messages.
- In your manifest.toml, declare a headless task to receive ADM messages and use as the component ID. IMPORTANT: Replace with your specific package id.
- In your App.ts, register your app with the Device Messaging service and receive a registration ID.
- Create a task.js and register the
HeadlessTaskwithHeadlessEntryPointRegistry.
- Create an AdmHeadlessTask.ts file. The basic structure of the file has the following format.
- In AdmHeadlessTask.ts, implement the
AmazonDeviceMessagingHandlerinterface in your headless task to handle ADM messages.
- Pass the handler as an argument to the
AdmHeadlessTask.
- Call
AmazonDeviceMessagingServer.registerHandler()to register the implementation ofAmazonDeviceMessagingHandlernamedhandler.
- After calling the
registerHandlermethod, callwaitForMessageHandlerCompletionAsync.
- Wait for the completion of
waitForMessageHandlerCompletionAsync. If the method doesn’t throw an error, it indicates successful handling of the message. If there is a failure when handling the message, ADM doesn’t reattempt the message delivery.
waitForMessageHandlerCompletionAsync method can throw an error when the handler doesn’t process the message within the time specified by waitDuration or it fails to process the message. These errors are reported to the Lifecycle Manager and it is up to your app to handle them.
Example AdmHeadlessTask.ts
Classes
Modules
- index
- turbo-modules/AmazonDeviceMessagingHandler
- turbo-modules/AmazonDeviceMessagingHandler
- turbo-modules/AmazonDeviceMessagingServer
- turbo-modules/AmazonDeviceMessagingServer
- turbo-modules/AmazonDeviceMessagingTurboModule
- turbo-modules/AmazonDeviceMessagingTurboModule
- turbo-modules/types/Error
- turbo-modules/types/Error
- turbo-modules/types/Error
- turbo-modules/types/Response
- turbo-modules/types/Response
- turbo-modules/types/Response

