May 6, 2014 - APNs: âApple Push Notification service SSL certificate. âApplication Private Key. ⢠GCM: âAPI Key
Engage Your Customers with Amazon SNS Mobile Push Constantin Gonzalez, Solutions Architect Amazon Web Services Germany GmbH
© 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
65% of mobile apps are abandoned within 90 days.
http://blog.flurry.com/bid/90743/App-Engagement-The-Matrix-Reloaded
“…understanding and improving user engagement is the new currency of doing business in the new digital world.” –Peter Farago, Flurry.com
http://blog.flurry.com/bid/90743/App-Engagement-The-Matrix-Reloaded
Mobile push notifications engage customers when your app is not currently active. • Users opt-in to receive them • Delivered to a specific app on a specific device • Short messages: read, ignore, or acknowledge to launch the app
In this session, we’ll cover: • How push notifications work. • A simple, scalable, robust & cross-platform way to deliver push notifications that you can start using now. • A real-world example for sending massive amounts of targeted push notifications to mobile users.
Push Notifications Under the Covers
Your cloud application directs mobile push notifications to a specific app on a specific device
Cloud App
Mobile Apps
Notifications are delivered via platform-specific push services, which keep connections with their devices.
Platform Service Cloud App
Mobile Apps
Developers manage tokens for each device, and must proactively swap or disable them based on feedback. Token Feedback
Platform Service
Token Registration
Challenges
Each platform-specific push service works differently.
Apple APNs
Google GCM
Amazon ADM
• Different APIs • Different Features • Different Feedback
Token Housekeeping Can be Complex Token Feedback
Platform Service
Token Registration
• Regularly connect to the platform service • Handle feedback for failed/ stale notifications • Blacklist tokens • Establish good reputation with platform services • etc.
Push notifications get even more complex as you scale to support millions of devices.
Cloud App
Platform Services
Mobile Apps
Amazon SNS Mobile Push
Amazon SNS Mobile Push is a managed, scalable, cross-platform push intermediary service. Apple Devices
Google Devices Amazon SNS Mobile Push
Kindle Devices
You can send a distinct payload for each platform, or publish one common message for all platforms. Publish
Apple
Publish
Google Kindle Fire
Kindle Fire
Apple
Google Kindle Fire
Kindle Fire
You can publish unique messages to individual devices, or broadcast identical messages to many devices at once. Direct Publishing
Broadcast with SNS Topics
Publish Publish Publish
Publish
Amazon SNS consumes feedback from each platform and manages swapping and disabling tokens on your behalf.
Token Feedback
Cloud App
Amazon SNS Mobile Push
Token Registration
• Write to one stable endpoint per device • You can access the feedback, but you don’t have to do so in order to use Amazon SNS
Getting Started
Step 1: Write your mobile app • Use the mobile app platform’s push notification libraries as you normally would.
Step 2: Obtain Application Prerequisites • APNs: – Apple Push Notification service SSL certificate – Application Private Key
• GCM: – API Key (Sender Auth Token)
• ADM: – Client ID – Client secret
Step 3: Register Your Mobile App with AWS
Amazon SNS Mobile Push
Step 4: Obtain a Token/Registration ID from the device
• APNs: – Device Token
• GCM: – Registration ID
Cloud App
• ADM: – Registration ID
• For existing devices
arn:aws:sns:eu-west-1:12…1f
Step 5: Add Token/Registration ID to Amazon SNS
Cloud App
– Use the console for .csv import Amazon SNS Mobile Push
– Or use CreatePlatformEndpoint API
• For future devices – Use a proxy server and the CreatePlatformEndpoint API – Or use the AWS token vending service and let devices register themselves
• Receive an ARN back
Step 6a: Send Push Notifications via the Console
Hello world!
Step 6b: Send Push Notifications via the API MyMac:~ glez$ python Python 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import boto >>> import boto.sns >>> boto.sns.connect_to_region("eu-west-1").publish( ... message="Hello world!", ... target_arn="arn:aws:sns:eu-west-1:979463966312:endpoint/APNS_SANDBOX/ Push2reInvent/fc1234a1-67ef-4f62-b31a-ac320bf7631f") {u'PublishResponse': {u'PublishResult': {u'MessageId': u'1893fa9d-7478-5137be1d-b06928d999d0'}, u'ResponseMetadata': {u'RequestId': u'c3c26267-92af-50b3-b529-2893ce0e4854'}}} >>>
Step 7: Receive
User/Device management • Use CreatePlatformEndpoint to register new tokens/IDs along with user data
• Use ListEndpointByPlatformApplication to discover registered endpoints • Manage ARNs and associated data in Amazon DynamoDB • Publish to individual ARNs, or • Use Amazon SNS topics for 1:many messaging • Coordinate publishing with Amazon SQS or Amazon SWF
Demo
Quick Review
Amazon SNS Mobile Push
• Cross-platform push to Apple, Google and Amazon • Seamless scalability with durable, reliable deliveries • Easy token management • 1m free per month, and $1.00 per million thereafter
Mirrorball Slots – Mobile
Mirrorball Slots - Challenges
Plumbee customers ask for notifications!
“Some of us have very busy lives and can’t be checking the game 24/7. It would be great to get a notification when a challenge starts. Thanks!”
Use cases Retention / Reactivation • Day 2, day 7 retention • active players (active in 7 days) • D7,D10,D14,D21,D28 reactivation • Challenge start/ends/redemption • New features/games
Targeted promotions • Spender categorisation • Last spent • New user promos • Time-limited promo start/end
Design Goals
• Easy to add new campaigns • Fine grained targeting • Scales linearly
Building blocks
Data Collection
Targeting
Mobile Push
Data Collection
Data Collection • Collect everything • There is no such a thing as too much data! • Targeting only as effective as your data • Fine granularity depends on data analysis
Data Collection log actions
log log
Application Servers
Analytics Amazon SQS
Device Registration – Code example private String getArnForDeviceEndpoint( String platformApplicationArn, String deviceToken) { CreatePlatformEndpointRequest request = new CreatePlatformEndpointRequest() .withPlatformApplicationArn(platformApplicationArn) .withToken(deviceToken); CreatePlatformEndpointResult result = snsClient.createPlatformEndpoint(request); return result.getEndpointArn(); }
Device Registration – Logging private String registerEndpointForApplicationAndPlatform( final long plumbeeUid, String platformARN, String platformToken) { final String deviceEndpointARN = getArnForDeviceEndpoint(platformARN, platformToken); sqsLogger.queueMessage(new HashMap() {{ put("notification", "register"); put("plumbeeUid", plumbeeUid); put("provider", platformName); put("endpoint", deviceEndpointARN); }}, null); }
return deviceEndpointARN;
Device Registration – Event example { "sId": "2fa5e687-c692-4c60-8bf9-19d3b3bef30f", "rId": "40f3aa74-1653-422f-a484-b98dbb32bda2", "timeStamp": 1381853084268, "testVariant": "", "m-mbs-app-service-version": "m-mbs-app-1381818956", "metadata": { "plumbeeUid": XXXXXXX, "notification": "register", "provider": "apns", "endpoint": "arn:aws:sns:useast-1:300361537691:endpoint\/APNS\/MIRRORBALL_SLOTS_CI\/ XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" } }
Data Collection (II) consume
Analytics Amazon SQS
archive
Apache Flume
Amazon S3 Event Logs
Data Collection (III)
Cluster
consume
KPIs update
store Event Logs
Amazon EMR
Amazon SNS
Amazon Redshift
Amazon S3
User Targeting
User targeting • SQL queries against Amazon Redshift • That’s it!
User targeting – Query example -- Target all mobile users SELECT plumbee_uid, arn FROM mobile_user
User targeting – Query example (II) -- Target lapsed users (1 week lapse) SELECT plumbee_uid, arn FROM mobile_user WHERE last_play_time < (now - 7 days)
User targeting – Query example (III) -- All the users that spend between 6h and 9h UTC on -- Mondays and didn't spend in the last 7 days SELECT plumbee_uid, arn FROM user_spending_activity WHERE time_slice = 3 AND plumbee_uid IN ( SELECT plumbee_uid FROM user_metrics WHERE last_purchase_time < (now - 7d)
Mobile Push
Mobile Push – Code example SNS publish private void publishMessage(UserData userData, String jsonPayload) { amazonSNS.publish(new PublishRequest() .withTargetArn(userData.getEndpoint()) .withMessageStructure("json") .withMessage(jsonPayload)); }
JSON payload { "default": "“The 5 day Halloween Challenge has started today! Touch to play now!”", "APNS": "{\"aps\" : {\"alert\":\"Halloween Challenged has started!"\",\"sound\":\"default\" },\"id\":\"XXXX\",\"tag \":\"challenge-start\" }" }
Mobile Push • Amazon SWF for orchestration • Amazon Redshift for targeting • Amazon SNS for the actual push
Mobile Push - Scheduling query
Scheduling
query
Publish Service
Amazon SWF
Mobile Push - Targeting query
Amazon SWF
target users
query
Amazon EC2 Worker (Segmentation)
Amazon Redshift
Amazon S3
Mobile Push - Processing batch 1 - N
batch N - M
partition
push
publish partition
push
publish Amazon EC2 Amazon SWF Children workflows Read data + push Decider (Batch Processing)
End User
Mobile Push - Reporting example The following message has been sent to NNNNNN devices in m min, ss sec: ““The 5 day Halloween Challenge has started today! Touch to play now!”” Targeting query: SELECT m_arn.plumbeeui, DISTINCT(m_arn.endpoint) FROM mobile.lu_user m_user, mobile.lu_notifications_arn m_arn WHERE m_user.plumbeeuid = m_arn.plumbeeuid AND country_code IN (:america) GROUP BY m_arn.endpoint Workflow Execution Stats * * * *
number number number number
of of of of
devices targeted: NNNNNN notifications sent: NNNNNN notifications that failed (excluding disabled devices): 0 disabled devices: NNNN
Click here for workflow execution details.
Day 2 retention - No Push vs Push Without Push
40
With Push
30 20 10 0 Day 1
Final Day
Redemption Day
Summary • Collect and analyze data: Amazon SQS, Amazon S3, Amazon EMR, Apache Flume, Amazon Redshift • Targeting: SQL queries • Mobile Push with Amazon SNS • Orchestration with Amazon SWF
Extensive SDK and IDE support enables you to build applications tailored to your language or platform. SDKs for your preferred platform and language…
Android
iOS
Java
nodeJS
.NET
…integrated into your preferred IDE
Eclipse
Visual Studio
CLI
Powershell
PHP
Python
Ruby
More Information • Amazon SNS Detail Page and Docs – http://amzn.to/179ee7r Amazon SNS Mobile Push
• Getting Started + Sample Apps – http://amzn.to/15rs1DV
• Email –
[email protected]
We hope your mobile app never gets abandoned!
Thank You! Constantin Gonzalez
[email protected] @zalez © 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.