In this deep-dive session, we outline how to leverage the appropriate AWS services for sending different types and sizes of data, such as images or streaming video. We'll cover common real-world scenarios related to authentication/authorization, access patterns, data transfer and caching for more performant Mobile Apps. You learn when you should access services such as Amazon Cognito, Amazon DynamoDB, Amazon S3, or Amazon Kinesis directly from your mobile app, and when you should route through Amazon API Gateway and AWS Lambda instead. Additionally, we cover coding techniques across the native, hybrid, and mobile web using popular open-source frameworks to perform these actions efficiently, and with a smooth user experience.
4. Table Stakes
- AuthN/AuthZ
- Fine-grained access control
- Static asset download/refresh
- File uploads (images, video, etc.)
- User/system notifications
- API interaction (GET, POST, etc.)
- REST, GraphQL, JSON-API
- Async communications
- Optimistic updates
- State
- User preferences (cross-device)
- Systems of record/tables
- Mutability
- Analytics
- Session information
- Custom events
5. Architecture Concerns
1. System
1. Scale
2. Costs
3. Security
2. App
1. Performance
• Network latency
• UX
• CPU
• Battery
2. Usability
• Accessibility
3. Security
4. State
Related:
Development team speed
New-joiner contribution
Shared skills
6. Architecture: System
Token exchange
Session storage
Dataset sync
Amazon
CloudFront
Amazon
S3 Amazon
DynamoDB
Amazon
RDS
Amazon
MobileAnalytics
Amazon
SNS
Amazon
Cognito
Amazon API
Gateway
virtual private cloud
AWS
Lambda
Amazon
EC2/Amazon
ECS
Session data
Custom event attributes
Custom metrics
Routing
API Negotiation
Static content
Images
Video
Binary data
Uploads
7. Granular Auth Controls
IAM Roles
• Fine-grained API access
• Enterprise SAML Federation
User Pool Lambda Triggers
Cognito Policy Variables
API Gateway Authorizers
• User Pool Authorizer
• Custom Authorizer
Takeaway:
Sort out Identity and Auth;
everything else gets easier
24. Network Management
Polling & connection setup are expensive
- Battery, CPU
- Wake devices via push then choose medium
- API Gateway GET/POST, Long Polling, Websocket, HTTP/2,
Amazon Cognito Sync, MQTT, etc.
Aggregate inbound/outbound messages
Re-use connections where possible
28. Cordova
Formerly known as PhoneGap
Create mobile apps with HTML, CSS,
JavaScript
Extended via plugins
WebView intermediary for
rendering/communicating with platform
Ionic
• UI framework built on Cordova using
Angular
29. Using AWS Services from Cordova
1. Download and include aws-sdk.min.js.
2. Reference in Cordova’s index.html:
3. Grant AWS endpoints access:
4. Call AWS SDK functions from index.js:
• Start with Amazon Cognito in onDevice
37. SDK Generation
- Native/Hybrid have SDKs bundled
- JavaScript SDK
- Builder: https://sdk.amazonaws.com/builder/js/
- Can use for Cordova too
- Use w/ Frameworks & tooling
- Deferred/selective loading
38. Common Mobile Web Requirements
• Reactive design for different form factors
• Non-blocking HTTP actions
• Auto refreshing
• State management
• Routing
• List Restaurants, view Menu/Orders
• Actions
• Place/Delete Orders
• ES6 syntax
39. Mobile Web by Example
• React/Angular
• Component-based design, minimize round-trips
• State updates and dynamic page refresh
• React Router
• /restaurants, /menu:id, /order:id
• Babel
• ES6 compiler
• Axios
• Promise-based XHR abstraction
• Materialize
• Reactive UX
• Based on Material Design
• Session Storage
• Keep track of latest operations
41. Toolbox
Webpack
- Code split on API Gateway
resources
- deferred loading, bundling
React Router
• Match routes with Services
- /Login Cognito
- Alternative: API Gateway
or ALB
- /* API Gateway {proxy+}
Infrastructure matters too!
- Core rendering as needed
- Homepage code shouldn’t block
login page or crypto libs
- Async load state when necessary
- User interactions
- Pagination
- Lazy load extra branches
42. Web Server Configuration
• S3 bucket
• Enable “Static Website” on bucket properties
• Creates: BUCKETNAME.s3-website-us-east-1.amazonaws.com (regions vary)
• Add access policy to bucket
• Browser GET = s3:GetObject
• Ensure CORS is enabled for XHR calls to API Gateway
43. Serverless Mobile Web Zoom-In
Amazon
CloudFront
Amazon
S3
API
Gateway
Mobile apps
1. Optional
CDN hosting
of content
2. Webpage loaded with
Script references
3. Browser downloads
critical libs first, lazy
load others
5. Script libraries use XHR
browser requests to API
Gateway stage endpoints
4. Cognito AuthN/AuthZ:
User Pools + Identity
Serverless
Express
wrapper
46. Native
Interrogates app lifecycle
- Background queue filled with
session and custom events
- Session events batched & sent
Backgrounded time > AWSValueSessionResumeDelay
- Custom events sent anytime
- Best practice: use
onPause, onStop,
onResume
SDK Session Management
Web
Configure default session length
Force event submission anytime
Window.localStorage ensures
persistence through browser/tab
exiting
47. Enhancing JavaScript Sessions
Debate: Apples vs. oranges?
Modern browsers offer visibilitychange() event:
https://developer.mozilla.org/en-US/docs/Web/Events/visibilitychange
extendSession()
stopSession()
48. Mobile Engagement
Emerging consumer pattern:
1. Mobile users making requests
2. Mobile users fulfilling requests
Needs:
1. Order tracking
2. Notifications (two-way)
3. SLA management
49. Emerging Pattern: Request Tracking
Amazon API
Gateway
Amazon
SQS
Amazon
SNS
Amazon
DynamoDB
AWS
Lambda
Amazon
SQS
Lambda #1
TimeStamp CognitoID Acknowledged
DelaySeconds =
15 mins
Lambda #2
SLA:TimeStamp+30min
= expTimeStamp
remaining =
expTimeStamp – Time.Now()
IF remaining >0 {
//Resubmit to SQS w/
//visibility timeout remaining
}ELSE{
//Business escalation logic
}
Poll for new
messages
Amazon
MobileAnalytics
50. Final Thoughts
Think Big & apply known patterns to new industries
Tools designed for one domain can be used in others
You can optimize and enhance on all platforms
- Hire to build a good culture
Focus on client & infrastructure end-to-end interactions