Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013

on

  • 1,793 views

Connecting your mobile app to AWS can unlock powerful features. With AWS, you can streamline your sign-in experience with social login, store user data in the cloud and share it between devices, ...

Connecting your mobile app to AWS can unlock powerful features. With AWS, you can streamline your sign-in experience with social login, store user data in the cloud and share it between devices, display location-specific information using geospatial queries, and engage your customers across multiple platforms with push notifications. In this session, you learn how to integrate these powerful features into a sample mobile app using Amazon DynamoDB, Amazon Simple Notification Service (Amazon SNS), and web identity federation.

Statistics

Views

Total Views
1,793
Views on SlideShare
1,670
Embed Views
123

Actions

Likes
3
Downloads
47
Comments
0

2 Embeds 123

http://www.scoop.it 122
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013 Presentation Transcript

  • 1. Building Cloud-backed Mobile Apps Glenn Dierkes, AWS Mobile November 13, 2013 © 2013 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.
  • 2. Session Goals • Cloud services, great apps • Apps today – – – – Social Logins Geo Tagging File and Data Storage Push Notifications
  • 3. AWS Mobile Landscape User Data Social Login Mobile Push File Storage Amazon DynamoDB AWS IAM Amazon S3 Amazon SNS
  • 4. Demo of the Mobile Photo Share sample App An app to share geo-tagged photos with others.
  • 5. Mobile Photo Share – Architecture Geo Library for Amazon DynamoDB Geo AWS IAM Web Identity Federation AWS Mobile SDKs S3 Transfer Manager Amazon S3 Amazon DynamoDB
  • 6. Web Identity Federation Geo Library for Amazon DynamoDB Geo AWS IAM Web Identity Federation AWS Mobile SDKs S3 Transfer Manager Amazon S3 Amazon DynamoDB
  • 7. Web Identity Auth Flow Access Policy Mobile Client ${id} Amazon S3 Bucket AWS STS AWS Cloud
  • 8. Web Identity Federation • Social Logins – Managing Users is hard – Allow users to connect with their existing accounts. • Facebook, Google, and Amazon. – Provides restricted temporary AWS Credentials • Policy variables • Don’t put credentials in your app’s code (can’t rotate, not secure) • Learn More – SEC401 session with Bob Kinney (Thursday 1:30 – 2:30 pm) – https://mobile.awsblog.com/post/Tx3UKF4SV4V0LV3
  • 9. S3 Transfer Manager Geo Library for Amazon DynamoDB Geo AWS IAM Web Identity Federation AWS Mobile SDKs S3 Transfer Manager Amazon S3 Amazon DynamoDB
  • 10. Amazon S3 Transfer Manager • Upload/Download files to/from Amazon S3 – Pictures – Videos – Music • Pause, Resume, Cancel • Efficiency and failure tolerance • No backend
  • 11. Amazon S3 Transfer Manager – Demo • Upload Photo Page from Mobile Photo Share • View Photo Page from Mobile Photo Share
  • 12. Amazon S3 Multipart Upload -(void)multipartUpload:(NSData*)dataToUpload inBucket:(NSString*)bucket forKey:(NSString*)key { S3InitiateMultipartUploadRequest *initReq = [[S3InitiateMultipartUploadRequest alloc] initWithKey:key inBucket:bucket]; S3MultipartUpload *upload = [s3 initiateMultipartUpload:initReq].multipartUpload; S3CompleteMultipartUploadRequest *compReq = [[S3CompleteMultipartUploadRequest alloc] initWithMultipartUpload:upload]; int numberOfParts = [self countParts:dataToUpload]; for ( int part = 0; part < numberOfParts; part++ ) { NSData *dataForPart = [self getPart:part fromData:dataToUpload]; S3UploadPartRequest *upReq = [[S3UploadPartRequest alloc] initWithMultipartUpload:upload]; upReq.partNumber = ( part + 1 ); upReq.contentLength = [dataForPart length]; upReq.stream = stream; S3UploadPartResponse *response = [s3 uploadPart:upReq]; [compReq addPartWithPartNumber:( part + 1 ) withETag:response.etag]; } [s3 completeMultipartUpload:compReq]; }
  • 13. Amazon S3 Multipart Upload (cont.) -(NSData*)getPart:(int)part fromData:(NSData*)fullData { NSRange range; range.length = PART_SIZE; range.location = part * PART_SIZE; int maxByte = (part + 1) * PART_SIZE; if ( [fullData length] < maxByte ) { range.length = [fullData length] - range.location; } return [fullData subdataWithRange:range]; } -(int)countParts:(NSData*)fullData { int q = (int)([fullData length] / PART_SIZE); int r = (int)([fullData length] % PART_SIZE); return ( r == 0 ) ? q : q + 1; }
  • 14. Amazon S3 Transfer Manager – Code // 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];
  • 15. Amazon S3 Transfer Manager • Learn More – http://mobile.awsblog.com/post/TxIRFEQTW9XU8G – http://aws.amazon.com/mobile/
  • 16. Geo Library for Amazon DynamoDB Geo Library for Amazon DynamoDB Geo AWS IAM Web Identity Federation AWS Mobile SDKs S3 Transfer Manager Amazon S3 Amazon DynamoDB
  • 17. Geo Library for Amazon DynamoDB • Java Library – Produces geo-hash indexes for use with DynamoDB • Used in a middle-tier – Helps to minimize client side networking and data manipulation • Geo-tagged data – Example: Store Locator
  • 18. Geo Library for Amazon DynamoDB Amazon DynamoDB Geo Geo Library for Amazon DynamoDB • • • • • getPoint putPoint deletePoint queryRadius queryRectangle
  • 19. Geo Library for Amazon DynamoDB – Demo • Picture Map from Mobile Photo Share
  • 20. Geo Library for Amazon DynamoDB – Server Code // Setup the Amazon DynamoDB Client AmazonDynamoDBClient ddb = new AmazonDynamoDBClient( credentials ); ddb.setRegion( Region.getRegion( Regions.fromName( "us-east-1" ) ) ); // Configure the GeoDataManager GeoDataManagerConfiguration config = new GeoDataManagerConfiguration( ddb, "Photos" ); // Create the GeoDataManager GeoDataManager geoDataManager = new GeoDataManager( config );
  • 21. Geo Library for Amazon DynamoDB – Server Code // Requesting a geo-query server-side GeoPoint centerPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng")); // Identify attributes to return from DynamoDB table List<String> attributesToGet = new ArrayList<String>(); attributesToGet.add( “title” ); attributesToGet.add( “userId” ); QueryRadiusRequest request = new QueryRadiusRequest( centerPoint, 5000 ); request.getQueryRequest().setAttributesToGet( attributesToGet ); // Submit the request through the Geo Library QueryRadiusResult queryRadiusResult = geoDataManager.queryRadius( queryRadiusRequest );
  • 22. Geo Library for Amazon DynamoDB – Server Code // Analyzing the results Map<String, AttributeValue> geoItems = geoQueryResult.getItem(); List<String> resultArray = new ArrayList<String>(); for (Map<String, AttributeValue> item : geoItems ) { String userId = item.get( "userId” ).getS(); String title = item.get( “title” ).getS(); if ( filterUserId.equalsIgnoreCase( userId ) || title.startsWith( “public” ) ) { resultArray.add( title ); } } return resultArray;
  • 23. Geo Library for Amazon DynamoDB • Learn More Here – https://github.com/awslabs/dynamodb-geo – http://mobile.awsblog.com/post/TxWTJOSLE7O3J2/ • Sample – Provides an AWS Elastic Beanstalk middle tier – iOS App
  • 24. AWS Mobile SDKs Geo Library for Amazon DynamoDB Geo AWS IAM Web Identity Federation AWS Mobile SDKs S3 Transfer Manager Amazon S3 Amazon DynamoDB
  • 25. AWS Mobile SDKs – Demo • Favorite Pictures from Mobile Photo Share
  • 26. AWS Mobile SDKs • Supports a number of AWS services • Amazon DynamoDB, Amazon S3 • Amazon SQS, Amazon SNS, and more • Fine-grained access control • Segregates user data in DynamoDB • Multiple Platforms • iOS • Android
  • 27. AWS Mobile SDKs – Pattern Consistent usage pattern • • • • Create the service client Create the request Submit the request Process the results
  • 28. AWS Mobile SDKs – get favorites // Create the client AmazonDynamoDBClient *ddb = [[AmazonDynamoDBClient alloc] initWithCredentialsProvider:self.provider]; // Create the get request DynamoDBAttributeValue *userId = [[DynamoDBAttributeValue alloc] initWithS: [AmazonKeyChainWrapper userId]]; DynamoDBGetItemRequest *getItemRequest = [DynamoDBGetItemRequest new]; getItemRequest.tableName = DYNAMODB_TABLENAME; getItemRequest.key = [NSMutableDictionary dictionaryWithObject:userId forKey:@"UserId"]; getItemRequest.consistentRead = YES; // Submit the request DynamoDBGetItemResponse *getItemResponse = [ddb getItem:getItemRequest]; // Process the results DynamoDBAttributeValue *favorites = [getItemResponse.item valueForKey:@"Favorites"]; return favorites.sS;
  • 29. AWS Mobile SDKs – put favorites // Create the put request DynamoDBPutItemRequest *putItemRequest = [DynamoDBPutItemRequest new]; putItemRequest.tableName = DYNAMODB_TABLENAME; DynamoDBAttributeValue *userId = [DynamoDBAttributeValue new]; userId.s = theUserId; DynamoDBAttributeValue *newFavorites = [DynamoDBAttributeValue new]; newFavorites.sS = theFavorites; [putItemRequest.item setValue:userId forKey:@"UserId"]; [putItemRequest.item setValue:newFavorites forKey:@"Favorites"]; // Submit the request [ddb putItem:putItemRequest];
  • 30. AWS Mobile SDKs • Learn More Here – http://mobile.awsblog.com/post/Tx1U4RV2QI1MVWS/ – AWS SDK for Android • http://aws.amazon.com/sdkforandroid – AWS SDK for iOS • http://aws.amazon.com/sdkforios
  • 31. SNS Mobile Push • Push Notifications – Single Topic – Push to users all platforms • Apple, Amazon, Google • Push to individual devices – Console for easy setup • Certificates • Keys
  • 32. SNS Mobile Push – Register Device Create a Platform Application • • • Specify the support push notification service (APNS, GCM, etc.) Console Platform Application ARN // Registering a device SNSCreatePlatformEndpointRequest *request = [SNSCreatePlatformEndpointRequest new]; request.customUserData = @"Here's the custom data for the user."; request.token = deviceTokenString; request.platformApplicationArn = @”The Platform Application ARN”; [snsClient createPlatformEndpoint:request];
  • 33. SNS Mobile Push • Publish – AWS Management Console – AWS SDKs • Learn More Here – http://aws.typepad.com/aws/2013/08/push-notifications-to-mobiledevices-using-amazon-sns.html – http://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html – MBL308 session (Friday 9:00 – 10:00 am) • Engage Your Customers with Amazon SNS Mobile Push
  • 34. AWS Mobile • Mobile Development Center – http://aws.amazon.com/mobile • Get Help – Forum https://forums.aws.amazon.com/forum.jspa?forumID=88 – Stack Overflow
  • 35. AWS Mobile – Next Steps • Mobile Photo Share – Server and iOS App – https://github.com/awslabs/reinvent2013-mobile-photo-share • Other samples and SDKs – https://github.com/awslabs/aws-sdk-android-samples – https://github.com/awslabs/aws-sdk-ios-samples
  • 36. Connect • Booth & Office Hours – Thursday 4:30 – 5:30 pm – Friday 9:00 – 10:00 am • AWS Mobile Blog – http://mobile.awsblog.com • Twitter – @awsformobile
  • 37. Please give us your feedback on this presentation MBL402 As a thank you, we will select prize winners daily for completed surveys!