Building Cloud-powered Mobile Apps Jenny Sun, AWS Solution Architect August 30, 2014
Session Goals Mobile Apps on AWS How to build a mobile app today? Social Logins Geo Tagging File and Data Storage Push Notifications Data Analytics User Profile Synchronization
释 放 创 造 力 一 切 将 会 怎 样 如 果 我 们 改 变 人 们 的 移 动 阅 读 方 式?
释 放 创 造 力 一 切 将 会 怎 样 如 果 我 们 改 变 人 们 的 旅 行 方 式?
AWS powers today s hottest startups
The Right Partner from Zero to Global Scale acquired by Facebook for $1B April 2012 valued at $3B November 2012 valued at $2.5B February 2013 acquired by Yahoo! for $1.1B May 2013 acquired by Google for $1.1B June 2013 acquired by Facebook April 2013
亚 马 逊 AWS 可 能 是 对 移 动 和 Web 应 用 程 序 开 发 者 而 言 最 重 要 的 事 情 杰 夫 贝 佐 斯 (Jeff Bezos) 偶 然 或 者 也 许 是 有 意 推 动 了 整 个 一 代 应 用 程 序 的 开 发 Steve Blank
云 就 如 同 培 养 创 业 公 司 的 沃 土 Eric Ries
How to build a mobile app today?
Authenticate users Manage users and identity providers Store and share media Store user-generated photos Media and share them Authorize access Securely access cloud resources Synchronize data Sync user prefs across devices Analyze User Behavior Track active users, engagement Track Retention Manage funnels, Campaign performances Your Mobile App Deliver media Automatically detect mobile devices Deliver content quickly globally Send push notifications Bring users back to your app by sending messages reliably Store shared data Store and query fast NoSQL data across users and devices Stream real-time data Collect real-time clickstream logs and take actions quickly
Introducing AWS Mobile Services Integrated SDK Your Mobile App, Game or Device App AWS Mobile SDK, API Endpoints, Management Console Mobile Optimized Services Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push Mobile Optimized Connectors Kinesis Connector DynamoDB Connector S3 Connector SQS Connector SES Connector Core Building Block Services Compute Storage Networking Analytics Databases AWS Global Infrastructure (10 Regions, Availability Zones, 51 Edge Locations)
Cross-platform, Optimized for Mobile User identity & data synchronization service Fast cross-platform Analytics & reporting Service Powerful Cross-platform Push notification service Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push Kinesis Connector DynamoDB Connector S3 Connector SQS Connector SES Connector Recorder that can handle intermittent network connection Store any NoSQL data and also map mobile OS specific objects to DynamoDB tables Easily upload, download to S3 and also pause, resume, and cancel these operations Access distributed buffering and queuing service Send email reliably from device
Fully Integrated AWS Mobile SDK Common authentication mechanism across all services Automatically handle intermittent network connections Cross-platform Support: Android, ios, Fire OS (Unity, PhoneGap, Cordova coming soon) Native SDKs optimized for Mobile OS, for example, uses the local offline caching architecture Reduced memory footprint; Pick and choose the service jars you need
Authenticate users Manage users and identity providers Store and share media Store user-generated photos Media and share them Authorize access Securely access cloud resources Synchronize data Sync user prefs across devices Analyze User Behavior Track active users, engagement Track Retention Manage funnels, Campaign performances Your Mobile App Deliver media Automatically detect mobile devices Deliver content quickly globally Send push notifications Bring users back to your app by sending messages reliably Store shared data Store and query fast NoSQL data across users and devices Stream real-time data Collect real-time clickstream logs and take actions quickly
Authenticate users Amazon Cognito (Identity Broker) Store and share media Amazon S3 Transfer Manager Authorize access AWS Identity and Access Management Synchronize data Amazon Cognito (Sync) Analyze User Behavior Amazon Mobile Analytics Track Retention Amazon Mobile Analytics Your Mobile App AWS Mobile SDK Deliver media Amazon CloudFront (Device Detection) Send push notifications Amazon SNS Mobile Push Store shared data Amazon DynamoDB (Object Mapper) Stream real-time data Amazon Kinesis (Recorder)
Authenticate users Amazon Cognito (Identity Broker) Store and share media Amazon S3 Transfer Manager Authorize access AWS Identity and Access Management Synchronize data Amazon Cognito (Sync) Analyze User Behavior Amazon Mobile Analytics Track Retention Amazon Mobile Analytics Your Mobile App AWS Mobile SDK Deliver media Amazon CloudFront (Device Detection) Send push notifications Amazon SNS Mobile Push Store shared data Amazon DynamoDB (Object Mapper) Stream real-time data Amazon Kinesis (Recorder)
Authenticate users: Amazon Cognito
Introducing Amazon Cognito Your App data is secure, available offline, and kept in sync between devices Simplifies Identity and Access Management Cross-device and Cross-platform Sync Implement security best practices Guest Manage unique identity for your user across identity providers Asynchronously sync user data across devices and platforms Securely access AWS services from Mobile device
Amazon Cognito Identity Joe Anna Bob Unique Identities Support Multiple Login Providers Easily integrate with major login providers for authentication. Unique Users vs. Devices Manage unique identities. Automatically recognize unique user across devices and platforms. Helps implement security best practices Securely access any AWS Service from mobile device. It simplifies the interaction with AWS Identity and Access Management Mobile Analytics S3 DynamoDB Kinesis Identity Providers Any Device Any Platform Any AWS Service
Amazon Cognito for Unauthenticated Identities Guest User Access Securely access AWS resources and leverage app features without the need to create an account or logging in Save Data to the Cloud Save app and device data to the cloud and merge them after login Visitor Preferences Guest Unique Identifier for Your Things Headless connected devices can also securely access cloud services. EC2 S3 DynamoDB Kinesis Cognito Store
Getting Started with Cognito in 3 steps Sign up for AWS Account and login to AWS Management Console Create identitypool for authenticated and unauthenticated users in the AWS Console Download and integrate the Mobile SDK and store and sync user data in a dataset
Demo: Amazon Cognito Console
Web Identity Auth Flow Developer Login End Users OAUTH/OpenID Access Token Access Token Pool ID Role ARNs Cognito ID, Temp Credentials Cognito Identity Broker S3 Mobile Analytics AWS Management Console DynamoDB App w/sdk Access to AWS Services User ID (Temp Credentials) Cognito Sync Store
Authorize access: Amazon Cognito + AWS IAM + Finegrained access control
Amazon Cognito (Identity Broker) Identity Providers Web Identity Federation AWS Account Identitypool identitypool authenticated identities Unauthenticated Identities Access Policy Access to AWS Services Pool of identities that share the same trust policy AWS IAM Roles S3 Get Delete Put DynamoDB
Access Policy for the IAM Role Allow Actions: All S3, Sync store Operations Resource: All resources within these services Deny Actions: All DDB Operations Resource: All resources { } { } { } "Effect":"Allow", "Action":["s3:*"], "Resource":"*" "Effect": Deny", "Action": ["dynamodb:*"], "Resource": "*" "Effect": "Allow", "Action": [ cognito-sync:*"], "Resource": "*"
Synchronize data across devices : Amazon Cognito (Sync)
What have customers told us about Synchronized Profile People have multiple devices and want to transition between devices. Implementing a user profile that syncs across devices, OS, apps is hard. It not only has to work when offline, but easy to integrate with existing apps.
Amazon Cognito Sync 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 User Data Storage and Sync Identity pool k/v data Work Offline Data always stored in local SQLite DB first. Works seamlessly when intermittent or no connectivity Any Platform ios/android/fireos
Amazon Cognito Sync Offline: The client SDK manages a local SQLite data store to allow the app to work even when connectivity is not available. Fast: The methods to read and write data only interact with the local SQLite database. Intelligent Sync: The sync method compares the local version of the data to the cloud sync store, pushes up deltas and pulls down new changes. Local SQLite Cache Flexible Conflict resolution: The sync method first reads the changes then writes its local changes to the cloud sync store By default Cognito assumes that the last write wins. Developers can override and implement their own conflict resolution programmatically
Integrating Cognito Sync functionality is dead simple Initialize the CredentialsProvider and CognitoClient provider = new CognitoCredentialsProvider(context, AWS_ACCOUNT_ID, COGNITO_POOL_ID, COGNTIO_ROLE_UNAUTH, COGNITO_ROLE_AUTH); cognito = new DefaultCognitoSyncClient(context, COGNITO_POOL_ID, provider); Create or open Dataset and Add Key Values cognito.openorcreatedataset(datasetname); dataset.put(key, value); Call synchronize on the dataset dataset.synchronize(new SyncCallback(){..});
Integrating Cognito Sync functionality is dead simple ios Initialize the AWSCognitoSyncClient AWSCognitoSyncClient *syncclient = [[AWSCognitoSyncClient alloc] initwithconfiguration: configuration]; Create or open Dataset and Add Key Values DataSet *dataset = [syncclient openorcreatedataset:@"mydataset"]; NSString *value = [dataset readstringforkey:@"mykey"]; [dataset putstring:@"my value" forkey:@"mykey"]; Call synchronize on the dataset [dataset synchronize];
Analyze User Behavior: Amazon Mobile Analytics
User Analytics Is the Most Adopted Mobile Developer Tool
What Customers Told Us About Mobile Analytics Developers deeply value user analytics and consider it an integral part of their app development process. They want to monitor their most important metrics in a timely manner, and take action quickly. They would like to own their mobile data, just like they do with any other AWS service.
Amazon Mobile Analytics Easily collect, visualize and understand your app usage data at scale Fast Scalable and Generous Free Tier Own Your Data Focus on metrics that matter. Usage reports available within 60 minutes of receiving data from an app Scale to billions of events per day from millions of users. Data collected are not shared, aggregated, or reused
Getting Started with Mobile Analytics in 3 steps Sign up for AWS Account and create or use existing Cognito ID in the AWS Management Console Download and integrate the Mobile SDK with one line of code (Android/FireOS, ios) View engagement and session activity reports in the AWS Management console within minutes
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
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
Track Custom Events 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, to each custom event Examples Track the number of Likes/Shares, per article, in a news app Number of songs played, per user session, in a music app In-app item popularity in a shopping app Understand player abort rates per level, in a game
Integrating Mobile Analytics is super simple Initialize the AmazonMobileAnalyticsClient. That s it! Get Session Activity in the AWS Management Console. analytics = new AmazonMobileAnalytics(provider, context, "SnakeGameAWS ); Add OnResume() and OnPause() analytics.getsessionclient().resumesession(); analytics.getsessionclient().pausesession(); Analytics.getEventClient().submitEvents(); For Custom Events activity reports, add events. EventClient eventclient = analytics.geteventclient(); MobileAnalyticsEvent visitevent = eventclient.createevent("speedset"); eventclient.recordevent(visitevent);
Integrating Mobile Analytics is super simple ios Initialize the AmazonMobileAnalytics object. That s it! Get Session Activity in the AWS Management Console. AWSMobileAnalytics* analytics = [AWSMobileAnalytics defaultawsmobileanalyticswithidentifier:@"someuniqueid"]; Create add Custom Events id<awsmobileanalyticseventclient> eventclient = analytics.eventclient; id<awsmobileanalyticsevent> level1event = [eventclient createeventwitheventtype:@"level1complete"]; Submit the event. If we don't call submitevents, events will automatically be submitted at periodic intervals. [eventclient submitevents];
Store and share media: Amazon S3
Amazon S3 Connector: Transfer Manager S3 Connector Multipart upload/download media to/from S3 (photos, videos, audio) No backend required Automatic retries Pause, resume, cancel functions Amazon S3
Amazon S3 Connector: Transfer Manager // Creating the transfer manager self.transfermanager = [S3TransferManager new]; self.transfermanager.s3 = s3client; // Upload image [self.transfermanager uploadfile:filename bucket:bucketname key:objectname]; // Download image [self.transfermanager downloadfile:filename bucket:bucketname key:objectname]; // Pause, Resume, Cancel [self.transfermanager pausealltransfers]; [self.transfermanager resumealltransfers]; [self.transfermanager cancelalltransfers];
Send Push Notifications: Amazon SNS Mobile Push
What Customers Told Us About Push Notifications Sending large-scale push notifications, cross-platform is still hard. Developers want to be able to reach their customers globally and across all devices.
Each platform works differently, and push gets even more complex as you scale to support millions of devices. Cloud App Platform Services Mobile Apps
Amazon SNS Mobile Push New features: ios Message Expiry Time Apple APNS Apple iphones and ipads Message Attributes Google GCM Android Phones and Tablets Industry s First! Internet Amazon SNS Cross-platform Mobile Push Baidu CP Amazon ADM Android Phones and Tablets in China Kindle Fire Devices New! Windows WNS and MPNS Windows Desktop and Windows Phone Devices With Amazon SNS, developers can send push notifications on multiple platforms and reach mobile users around the world
You can send a distinct payload for each platform, or publish one common message for all platforms. Publish Publish Apple Google Apple Google Kindle Fire Kindle Fire Kindle Fire Kindle Fire
Developers Love Cross-Platform Features of SNS Customers love high scale and Reliability of SNS High-profile Startups trust SNS for their high-profile launches Mature games increase retention using SNS Jetpack Joyride Secret.ly Fruit ninja Fast reliable notification for every Email received is powered by SNS Launched its Android App with SNS, no provisioning required Advanced targeted notifications bring players back into the game
Collect real-time click-stream data: Amazon Kinesis Mobile Connector
Amazon Kinesis Connector for Mobile Apps Integrated AWS Mobile SDK AWS Mobile SDK Amazon Kinesis Kinesis enabled Apps on EC2 S3 Redshift Generic batching system that handles intermittent network connection and also optimize battery utilization For sophisticated User Behavior Analysis
Summary
Authenticate users Manage users and identity providers Store and share media Store user-generated photos Media and share them Authorize access Securely access cloud resources Synchronize data Sync user prefs across devices Analyze User Behavior Track active users, engagement Track Retention Manage funnels, Campaign performances Your Mobile App Deliver media Automatically detect mobile devices Deliver content quickly globally Send push notifications Bring users back to your app by sending messages reliably Store shared data Store and query fast NoSQL data across users and devices Stream real-time data Collect real-time clickstream logs and take actions quickly
Authenticate users Amazon Cognito (Identity Broker) Store and share media Amazon S3 Transfer Manager Authorize access AWS Identity and Access Management Synchronize data Amazon Cognito (Sync) Analyze User Behavior Amazon Mobile Analytics Track Retention Amazon Mobile Analytics Your Mobile App AWS Mobile SDK Deliver media Amazon CloudFront (Device Detection) Send push notifications Amazon SNS Mobile Push Store shared data Amazon DynamoDB (Object Mapper) Stream real-time data Amazon Kinesis (Recorder)
Key Takeaways Integrated SDK Your Mobile App, Game or Device App AWS Mobile SDK, API Endpoints, Management Console Mobile Optimized Services Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push Mobile Optimized Connectors Kinesis Connector DynamoDB Connector S3 Connector SQS Connector SES Connector Core Building Block Services Compute Storage Networking Analytics Databases AWS Global Infrastructure (10 Regions, Availability Zones, 51 Edge Locations)
Key Takeaways Integrated SDK Your Mobile App, Game or Device App AWS Mobile SDK, API Endpoints, Management Console Mobile Optimized Services Flexibility And Freedom of Choice Mobile Optimized Connectors Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push Cross Platform and Optimized for Mobile Fully integrated and easy to get started Kinesis Connector DynamoDB Connector S3 Connector SQS Connector SES Connector Core Building Block Services Compute Storage Networking Analytics Databases AWS Global Infrastructure (10 Regions, Availability Zones, 51 Edge Locations)
Get Started for Free! Amazon Cognito Free Tier (for first 12 months): 1 Million syncs/month + 10GB of storage for Amazon Cognito Amazon Mobile Analytics Free Tier: 100 Million events every month Amazon SNS Mobile Push Free Tier: 1 Million push messages every month
谢 谢! 更 多 资 料 请 参 考 : http://aws.amazon.com/mobile/ Website www.amazonaws.cn Blog blog.csdn.net/awschina Wechat AWS 中 国 Weibo weibo.com/amazonaws
Appendix..
Simple and predictable pay as you go pricing Amazon Cognito Free Tier (for first 12 months): 1 Million syncs/month + 10GB of storage for Amazon Cognito Thereafter: $0.15 for 10K Syncs $0.15 per GB for storage Amazon Mobile Analytics Free Tier: 100 Million events every month Thereafter: $1.00 per Million events Amazon SNS Mobile Push Free Tier: 1 Million push messages every month Thereafter: $0.50 for Million notifications delivered $0.50 for Million requests