In this session, we will discuss how you can leverage the new cross-platform AWS Mobile Services to build a highly scalable and reliable mobile app, powered by the AWS cloud. We will explore core functionality like authentication and authorization of users, data synchronization, and back-end infrastructure without the need to manage servers. We'll also talk about understanding your user behavior, engaging your users, and bringing your users back to your app. No matter if you are building the next great social app, or a front-office enterprise mobile app, this session will discuss best practices for building reliable and scalable mobile apps.
17. ClientCode
ServerCode
HandlingTransientNetworkConditions
AWS Mobile
Services
AWS Mobile Services
ServerlessClient-Side
SDK
Mobile
Aware
SDK
provides
client-side
libraries to
interface
with
services
using
minimal
code
Code is
automatically
optimized to
manage
mobile
network and
transient
conditions
Fully
managed
infrastructure
Automatic
provisioning &
scaling
Just upload
code without
deploying
servers
18. AWS Mobile SDK: Fully Integrated
• Common authentication mechanism across
all services
• Automatically handle intermittent network
connections
• Cross-platform support: Android, iOS, Fire
OS, Unity, and JavaScript
• Native SDKs optimized for mobile OS, for
example, use the local offline caching
architecture
• Reduced memory footprint; pick and choose
the services you need
• Continuously updated with latest platform
enhancements
iOS Android Fire OS Unity
Xamarin
25. Amazon Cognito
Simplifies Identity and
Access Management
Securely access all
AWS services from
mobile device
Cross-device and
cross-platform sync
Implement security best
practices
“Your app data is secure, available offline, and kept in sync between devices”
Synchronize user’s data
across devices and
platforms
Manage users as
unique identities across
identity providers
Guest Your Own
Auth
26. Identity
Providers
Unique
IdentitiesJoe Anna Bob
Any Device
Any Platform
Any AWS
Service
Helps implement security best
practices
Securely access any AWS service from mobile
device. Simplified interaction with AWS Identity
and Access Management.
Support Multiple Log-In Providers
Easily integrate with major log-in providers for
authentication.
Unique Users vs. Devices
Manage unique identities. Automatically
recognize unique user across devices and
platforms.
Amazon Cognito Identity
Amazon
Mobile Analytics
Amazon
S3
Amazon
DynamoDB
Amazon
Kinesis
27. Amazon Cognito Flow
(Any OpenID Connect Token)
Amazon Cognito ID
(Temp Credentials)
Amazon
DynamoDB
End Users
Developer
App with
AWS Mobile
SDK
Access
to AWS
Services
Amazon Cognito
Identity Broker
Get OpenID Token
User Name
Password
Amazon Cognito ID,
Temp Credentials
Amazon S3
Amazon Mobile
Analytics
Amazon Cognito
Sync Store
AWS
Management
Console
OIDC Token
Pool ID
Role ARNs
User Authentication
System
(Running on AWS or not)
OIDC Token
OIDC Token
30. Amazon Cognito
Cloud Save and Sync
User Data
Storage and
Sync
Any Platform
iOS/Android/FireOS
Store App Data, Preferences, and State
Save app and device data to the cloud and merge
them after login.
Cross-Device Cross-OS Sync
Sync user data and preferences across devices
with one line of code.
Work Offline
Data always stored in local SQLite DB first.
Works seamlessly when intermittent or no
connectivity.
k/v data
Identity Pool
No Back End
Simple client SDK eliminates need for server
side code.
31. Synchronize Data Across Devices with
Amazon Cognito
Sync game states
across OS/devices
State transition
(link multiple accounts)
Sync user profiles
across OS/devices/web
32. Amazon Cognito Sync Data Model
• Identity Pool: Pool of app users. Can be shared
across apps.
• Identity: An individual user. Consistent across
identity providers. Can be a guest user.
• Dataset: Per user grouping of data. The most
granular level of sync. Up to 1 MB.
• Record: Key-value pair.
AWS Account
Dataset
Identity
Identity
Identity
Dataset
Dataset
Identity
Pool
1:60
1:n
1:20
Dataset
Dataset
Record
1:1024
You
Your App
Your App Users
User Data
Container
User Data
33. Integrating Amazon Cognito Sync
Functionality Is Dead Simple
Initialize the CredentialsProvider and CognitoClient
Call synchronize on the dataset
Create or open the dataset and add key values
provider = new CognitoCachingCredentialsProvider (context, AWS_ACCOUNT_ID,
COGNITO_POOL_ID, COGNITO_ROLE_UNAUTH, COGNITO_ROLE_AUTH, Regions.US_EAST_1);
cognito = new CognitoSyncManager (context, Regions.US_EAST_1, provider);
dataset.synchronize(new SyncCallback(){..});
cognito.openOrCreateDataset(datasetName);
dataset.put(key, value);
34. Integrating Amazon Cognito Sync
Functionality Is Dead Simple
Initialize the AWSCognitoSyncClient
Call synchronize on the dataset
Create or open the dataset and add key values
DataSet *dataset = [syncClient openOrCreateDataSet:@"myDataSet"];
NSString *value = [dataset readStringForKey:@"myKey"];
[dataset putString:@"my value" forKey:@"myKey"];
AWSCognitoSyncClient *syncClient = [[AWSCognitoSyncClient alloc]
initWithConfiguration: configuration];
[dataset synchronize];
iOS
39. Amazon Mobile Analytics
Scalable and generous
free tier
Focus on metrics that
matter. Usage reports
available within 60
minutes of receiving data
from an app.
Fast
Scale to billions of
events per day from
millions of users.
Own your data
“Simply and cost-effectively collect and analyze your application usage data”
Data collected are not
shared, aggregated, or
reused
40. Getting Started with Amazon Mobile Analytics
in Three Steps
Sign up for an AWS account and create or use an existing
Amazon Cognito ID in the AWS Management Console
View engagement and session activity reports in the
AWS Management Console within minutes
Download and integrate the Mobile SDK with one line of
code (Android/FireOS, iOS)
41. Key Business Metrics
(with one line of code)
1. Monthly Active Users
(MAU)
2. Daily Active Users
(DAU)
3. New Users
4. Daily Sessions
5. Sticky Factor
6. 1-Day Retention
7. Avg. Revenue per DAU
8. Daily Paying Users
9. Avg. Paying DAU
42. Track Retention
User retention is a key
indicator to judge the
outcome of a marketing
campaign, new feature
introduction, UX changes,
app updates, etc.
Mobile Analytics provide four
charts to track daily or
weekly rate of returning
users, after first use of the
app.
43. Get behavioral insights into app-specific
actions that your users take.
Reports provide a view of how often custom
events occur. You can add further context
with attributes and metrics for each custom
event.
Examples
Track the number of
likes/shares, per
article, in a news app
Understand player
abort rates per
level, in a game
Number of songs
played, per user
session, in a music app
In-app item popularity
in a shopping app
Track Custom Events
50. Amazon
KinesisAWS
Mobile
SDK
Mobile-Optimized Connectors (AWS Mobile SDK)
Amazon S3
Integrated AWS Mobile SDK
Optimized for native OS
Multipart upload media
Fault tolerant download
Automatic retries
Pause, resume, cancel functions
Generic batching system
handles intermittent network
connection
Optimize battery utilization
Amazon
DynamoDB
51. Amazon S3 Connector: Transfer Manager
S3 Connector
Multipart upload media (photos, videos, audio)
Fault tolerant download (e.g. assets)
No back end required
Automatic retries
Pause, resume, cancel functions
Optimized for native OS
52. Amazon S3 Connector: Transfer Manager in Android
// Creating the transfer manager
TransferManager = new TransferManager(credentialProvider);
// Upload image
Upload upload = transferManager.upload(BUCKET_NAME, fileName, file);
// Download image
Download download = transferManager.download(BUCKET_NAME, mKey,
file);
// Pause, and Resume
try {
PersistableDownload = download.pause();
//do something if we didn’t abort
} catch(PauseException e) {
//do something if we aborted
}
download = transferManager.resumeDownload(persistableDownload);
59. AWS Lambda
Auto Scaling
(never under- or over-
provision)
Focus on business logic,
not infrastructure. Upload
your code; AWS Lambda
handles everything else.
Zero administration
Lambda scales the
infrastructure as needed
to match the event rate
and pay as you go.
Bring your own code
“Run your code in the cloud in response to events and scale without any
servers to manage”
Starting with JavaScript but
later with any language,
create threads and
processes, run batch scripts
or other executables.
60. Respond to events in real time
Map local functions to Lambda functions from within the SDK
Target, filter, and route Amazon SNS notifications
Apply custom logic to user preferences and game state
Java support (coming soon), AWS CloudTrail integration, enhanced
metrics and logging via Amazon CloudWatch
S3 event
notifications
DynamoDB
Streams
Amazon
Kinesis
events
Amazon
Cognito
eventsSNS
events
Custom
events
AWS Lambda
61. Adding a Lambda Back End to Your Mobile App
Is Simple
Initialize the LambdaFactory and define the interface for the functions
Call synchronize on the dataset
Create/Upload the Lambda function to the AWS Management Console
lambda = new LambdaInvokerFactory(context, Regions.US_WEST_2, provider);
//interface
@LambdaFunction(functionName="cloudFunction”)
String localFunction(String nameInfo);
lambda.localFunction(“Hello From “); // this will output “Hello From Lambda”
exports.handler = function(event, context) {
context.done(null, event + 'Lambda'); // SUCCESS with message
};
66. Amazon SNS
Cross-Platform
Mobile Push
Internet
Apple APNS
Google GCM
Amazon ADM
Windows WNS and
MPNS
Baidu CP
With Amazon SNS, developers can send push notifications on multiple platforms
and reach mobile users around the world
New features:
Delivery metrics via
CloudWatch
Trigger Lambda
functions from SNS
notifications
Amazon SNS Mobile Push
Android Phones and Tablets
Apple iPhones and iPads
Kindle Fire Devices
Android Phones and Tablets in China
iOS
Windows Desktop and Windows Phone
Devices
67. Reliable Push at Scale Takes Constant Work
35 AWS EC2 m3.xlarge instances
Home-rolled code based on Tornado
6 Load
Balancers
Constantly trying to
scale out, both at
process level and
server level
Fighting to maximize
throughput at packets
per second level
Never certain how
many pushes we were
sending or dropping
68. Now Using Amazon SNS Mobile Push
Zero to 500m+ daily
push notifications
almost overnight
Highest available
reliability and speed
Easy migration
$1 per million
mobile push deliveries 10m
170m
500m
Day 1 Day 2 Day 3
Daily SNS Mobile Push
Deliveries (millions)
…Rising