Menu
AWS Mobile
Developer Guide

Get Started

Overview

The AWS Mobile Android and iOS SDKs help you build high quality mobile apps quickly and easily. They provide easy access to a range of AWS services, including Amazon Cognito, AWS Lambda, Amazon S3, Amazon Kinesis, Amazon DynamoDB, Amazon Pinpoint and many more.

Set Up Your Backend

  1. Sign up for the AWS Free Tier.

  2. Create a Mobile Hub project by signing into the console. The Mobile Hub console provides a single location for managing and monitoring your app's cloud resources.

    To integrate existing AWS resources using the SDK directly, without Mobile Hub, see Setup Options for Android or Setup Options for iOS.

  3. Name your project, check the box to allow Mobile Hub to administer resources for you and then choose Next.

Android - JavaiOS - Swift
Android - Java
  1. Choose Android as your platform and then choose Next.

  2. Choose the Download Cloud Config and then choose Next.

    The awsconfiguration.json file you download contains the configuration of backend resources that Mobile Hub enabled in your project. Analytics cloud services are enabled for your app by default.

  3. Add awsconfiguration.json to your app.

    From your download location, place awsconfiguration.json into a res/raw Android Resource Directory in your Android project. Choose Next.

  4. You are now ready to connect your app to your newly setup backend. Choose Add the AWS Mobile SDK to connect to your backend.

iOS - Swift
  1. Pick iOS as your platform and choose Next.

  2. Choose the Download Cloud Config and then choose Next.

    The awsconfiguration.json file you download contains the configuration of backend resources that Mobile Hub enabled in your project. Analytics cloud services are enabled for your app by default.

  3. Add awsconfiguration.json file to your app.

    From your download location, place awsconfiguration.json into the folder containing your info.plist file in your Xcode project. Select Copy items if needed and Create groups in the options dialog. Choose Next.

    Remember

    Every time you create or update a feature in your Mobile Hub project, download and integrate a new version of your awsconfiguration.json into each app in the project that will use the update.

  4. You are now ready to connect your app to your newly setup backend. Choose Add the AWS Mobile SDK to your app.

Connect to Your Backend

Android - JavaiOS - Swift
Android - Java
  1. Prerequisites

    Install Android Studio version 2.33 or higher.

    Install Android SDK v7.11 (Nougat), API level 25.

  2. Your AndroidManifest.xml must contain:

    <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  3. Add dependencies to your app/build.gradle. These libraries enable basic AWS functions, like credentials, and analytics.

    dependencies { compile ('com.amazonaws:aws-android-sdk-mobile-client:2.6.7@aar') { transitive = true; } }
  4. Add the following code to the onCreate method of your main or startup activity. This will establish a connection with AWS Mobile. AWSMobileClient is a singleton that will be an interface for your AWS services.

    import com.amazonaws.mobile.client.AWSMobileClient; public class YourMainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AWSMobileClient.getInstance().initialize(this).execute(); } }

    Your app is now set up to interact with the AWS services you configured in your Mobile Hub project!

    Choose the Run icon in Android Studio to build your app and run it on your device/emulator.You should see a log in your Android logcat saying "Welcome to AWS!".

iOS - Swift
  1. Prerequisites

    Install Xcode version 8.0 or later.

  2. Install Cocoapods. From a terminal window run:

    sudo gem install cocoapods
  3. Create Podfile. From a terminal window, navigate to the directory that contains your project's .xcodeproj file and run:

:code:`pod init`.
  1. Add core AWS Mobile SDK components to your build.

    platform :ios, '9.0' target :'YourAppTarget' do use_frameworks! pod 'AWSMobileClient', '~> 2.6.6' # other pods end

    Then install dependencies by runnng:

    pod install --repo-update

    Use ONLY your .xcworkspace

    Use the .xcworkspace file generated by cocoapods for all further development. If you used the xcodeproj to open your project, close it now and do not use it again.

  2. Add the following code to your AppDelegate to establish a run-time connection with AWS Mobile.

    import UIKit import AWSMobileClient @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { return AWSMobileClient.sharedInstance().interceptApplication(application, didFinishLaunchingWithOptions: launchOptions) } }
  3. Optional: If you want to make sure you're connected to AWS, add the following code to your AppDelegate.

    import AWSCore AWSDDLog.add(AWSDDTTYLogger.sharedInstance) AWSDDLog.sharedInstance.logLevel = .info

Your app is now set up to interact with the AWS services you configured in your Mobile Hub project! Choose the run icon in the top left of the Xcode window or type Command-R to build and run your app. You should see a log in your output saying "Welcome to AWS!".

Next Steps