Front-End Web & Mobile
Amazon Pinpoint adds ADM, Baidu, APNs Token Authentication and Sandbox Channel for Push Notifications
This post was written by
Zach Barbitta, Amazon Pinpoint Sr. Product Manager Tech & Lomax Escarmant, Amazon Pinpoint Software Development Engineer.
Reaching your customers through push notifications is an important part of user engagement and retention. To enable push notifications for your mobile application, you use a push notification service such as Apple Push Notification service (APNs) or Firebase Cloud Messaging (FCM). Amazon Pinpoint supports both of these. Today, Amazon Pinpoint launches support for Amazon Device Messaging (ADM) and Baidu Cloud Push (Baidu) services as well as the APNs sandbox environment and APNs .p8 token authentication.
The ADM service is used to send push notifications to users of Amazon devices, such as Kindle Fire tablets and other Amazon devices that run your apps. The Baidu service enables you to send push notifications to millions of mobile devices in China. This is essential for Amazon Pinpoint customers who want to engage Android users in China.
Additionally, Amazon Pinpoint added the ability to use the APNs sandbox environment and authenticate using APNs .p8 tokens. APNs .p8 tokens allow you to use a single authentication token across all of your apps. APNs .p8 tokens eliminate the frustration of dealing with expired certificates. You can use the APNs sandbox environment to test your notifications before you ship your apps.
In this brief tutorial, we show how to add push notifications with ADM. Click the links for more information about Baidu, APNs Sandbox, or .p8 token authentication. For more information, see Getting Started with Amazon Pinpoint in the Amazon Pinpoint User Guide.
Enable mobile push notifications through ADM
To send a push notification to mobile devices using Amazon Pinpoint and ADM, you need the following:
- Amazon developer account
- Client ID and client secret from Amazon Device Messaging
- ADM registration ID (provided by the end device that contains the ADM platform)
Device integration
If you are already familiar with ADM and have ADM credentials, you can simply follow the steps for Integrating Your App with Amazon Device Messaging.
Your subclass implementation of com.amazon.device.messaging.ADMMessageHandlerBase is inside your Android app. The subclass should implement the following methods and perform the corresponding calls:
- onRegistered – Called when the device is registered with the ADM service. Provides the ADM registration ID needed to register the device with Amazon Pinpoint.
Call:
pinpointManager.getNotificationClient().registerDeviceToken(registrationId)
- onUnregistered – Called when the device is no longer registered with the ADM service.
- onMessage – Called when the device receives a message notification from ADM.
Call:
NotificaitonDetails details = NotificationDetailsBuilder.builder()
.intent(intent);
.intentAction(NotificationClient.ADM_INTENT_ACTION)
.build();
pinpointManager.getNotificationClient().handleCampaignPush(details)
Testing
To test, you need an Amazon Pinpoint application, an ADM client ID, and an ADM client secret. You should also augment your sample app to display the device token after registration. The device token can be retrieved by calling
PinpointManager::getNotificationClient().getDeviceToken()
The steps below use the AWS Command Line Interface (CLI):
1. Register ADM as a channel with your Amazon Pinpoint application, given the ADM client ID and the ADM client secret (This only needs to be done once).
# replace bracketed items with proper values
aws pinpoint update-adm-channel --application-id [YourPinpointAppId] --adm-channel-request "{
\"ClientId\": \"[ADM_CLIENT_ID]",
\"Enabled\": true,
\"ClientSecret\": \"[ADM_CLIENT_SECRET]"
}"
2. Install your ADM sample app on a device that has ADM enabled, and capture the generated device token.
3. Send a direct message to the device specifying the device token as the address.
Next steps
Please let us know which features or tutorials for using Amazon Pinpoint you are interested in. You can leave comments here and, as always, feel free to contact us on the AWS Mobile Development Forum.