Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Getting started

You are currently viewing the AWS SDK for Mobile documentation which is a collection of low-level libraries. Use the Amplify libraries for all new app development. Learn more

You can view the Mobile SDK API reference here.

Collecting analytics data for your app can be accomplished with Amazon Pinpoint or Amazon Kinesis.

Amazon Pinpoint is a fully managed AWS service that you can use to engage with your customers across multiple messaging channels using analytics captured from the device. You can send push notifications, emails, or text messages (SMS), depending on the purpose of your campaign. Features include:

Audience Segments - You can define dynamic segments based on data that's reported by your application, such as operating system or mobile device type. You can also import static segments that you define outside of Amazon Pinpoint.

Messaging Campaigns - A campaign sends tailored messages on a schedule that you define. You can create campaigns that send mobile push, email, or SMS messages. To experiment with alternative campaign strategies, set up your campaign as an A/B test, and analyze the results with Amazon Pinpoint analytics.

Transactional Messages - Keep your customers informed by sending transactional mobile push and SMS messages—such as new account activation messages, order confirmations, and password reset notifications—to specific users.

Analyze User Behavior - You can view trends about your users' level of engagement, purchase activity, and demographics. You can monitor your message traffic with metrics for messages sent and opened. Through the Amazon Pinpoint API, your application can report custom data, which Amazon Pinpoint makes available for analysis.

The Amplify CLI helps setup and configure Pinpoint within your application and connect with the AWS Mobile SDK.

Prerequisite: Install and configure the Amplify CLI

Set Up Your Backend

  1. Use the CLI to add analytics to your cloud-enabled backend and app.

    In a terminal window, navigate to your project folder (the folder contains your app .xcodeproj file), and add the SDK to your app.

    amplify add analytics
  2. When configuration for analytics is complete, a message appears confirming that you have configured local CLI metadata for this category. You can confirm this by viewing status.

    $ amplify status
    | Category | Resource name | Operation | Provider plugin |
    | --------- | --------------- | --------- | ----------------- |
    | Auth | cognitoabcd0123 | Create | awscloudformation |
    | Analytics | yourprojectname | Create | awscloudformation |
  3. To create your backend AWS resources run the following:

    amplify push

Manually Updating your IAM Policy:

Note The Amplify CLI adds the appropriate policies and permissions for you. The information provided here is provided if you are not using the Amplify CLI in your project.

The Amazon Pinpoint service requires permissions defined in an IAM policy to use the submitEvents API. If you are using long-term AWS credentials attached to an Amazon IAM user, attach the following policies to the role of that IAM user. If you are using temporary AWS credentials vended by Amazon Cognito Identity Pools, then attach the following policies to the Unauthenticated and/or Authenticated IAM roles of your Cognito Identity Pool. The role you attach the policies to depends on the scope of your application. For example, if you only want events submitted when users login, attach to the authenticated role. Similarly, if you want events submitted regardless of authentication state, attach the policy to the unauthenticated role. For more information on Cognito Identities authenticated/unauthenticated roles see here.

"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": ["mobiletargeting:UpdateEndpoint", "mobiletargeting:PutEvents"],
"Resource": ["arn:aws:mobiletargeting:*:${accountID}:apps/${appId}*"]

Connect to Your Backend

Use the following steps to add analytics to your mobile app and monitor the results through Amazon Pinpoint.

Add Analytics

Set up AWS Mobile SDK components as follows.

  1. The Podfile that you configure to install the AWS Mobile SDK must contain:
platform :ios, '9.0'
target 'YourAppName' do
pod 'AWSPinpoint'
pod 'AWSMobileClient'
# other pods

Run pod install --repo-update before you continue.

If you encounter an error message that begins [!] Failed to connect to GitHub to update the CocoaPods/Specs . . ., and your internet connectivity is working, you may need to update openssl and Ruby.

  1. Classes that call Amazon Pinpoint APIs must use the following import statements:
/** start code copy **/
import AWSPinpoint
import AWSMobileClient
/** end code copy **/
  1. To send events with Amazon Pinpoint, you'll instantiate a Pinpoint instance. We recommend you do this during app startup, so you can use Pinpoint to record app launch analytics. Edit the application(_:didFinishLaunchingWithOptions:) method of your app's AppDelegate.swift by adding a pinpoint instance property, and initializing the Pinpoint client as shown below:
class AppDelegate: UIResponder, UIApplicationDelegate {
/** start code copy **/
var pinpoint: AWSPinpoint?
/** end code copy **/
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
// Other didFinishLaunching code...
/** start code copy **/
// Create AWSMobileClient to connect with AWS
AWSMobileClient.default().initialize { (userState, error) in
if let error = error {
print("Error initializing AWSMobileClient: \(error.localizedDescription)")
} else if let userState = userState {
print("AWSMobileClient initialized. Current UserState: \(userState.rawValue)")
// Initialize Pinpoint
let pinpointConfiguration =
AWSPinpointConfiguration.defaultPinpointConfiguration(launchOptions: launchOptions)
pinpoint = AWSPinpoint(configuration: pinpointConfiguration)
/** end code copy **/
return true

Monitor Analytics

Build and run your app to see usage metrics in Amazon Pinpoint. When you run the previous code samples, the console shows a logged Session.

  1. To see visualizations of the analytics coming from your app, open your project in the Amazon Pinpoint console by running the following:
amplify console analytics
  1. Choose Analytics from the icons on the left of the console, and view the graphs of your app's usage. It may take up to 15 minutes for metrics to become visible.


Analytic events can be grouped into segments, allowing you to engage your users more deeply by tying their app usage behavior to push notification, email, or SMS messaging campaigns. Read more about this in the messaging section or click here to learn more about Amazon Pinpoint.