Get Started with the Mobile App Performance SDK

Overview

Akamai’s Mobile Application Performance (MAP) SDK enables app owners and developers to craft custom, differentiated experiences while optimizing and accelerating their app’s API and image requests over the Akamai Intelligent Platform. This SDK helps create seamless mobile experiences when connection speeds are slow, or even unavailable. The MAP SDK manages this by intelligently pre-positioning content on the mobile device. The SDK also provides you with real user and device insights, including custom metrics, that can help you tune mobile experiences over time.

 

Maintain a great user experience with the MAP SDK. 

  • Speed up performance by reducing requests to the origin.
  • Tailor app experiences to Network quality.
  • Position content on users' devices to maintain user experience even under poor network conditions.

 

Features of the SDK include

  • Universal Caching: reduces requests to the origin, increasing delivery function.
  • Network Awareness: adjusts the weight of content depending on network conditions.
  • SureRoute for Cellular: plans the most efficient path through the mobile network to Akamai's distributed Edge servers.
  • Contextual Pre-Positioning: positions content on users' devices for retrieval in poor network conditions.
  • Mobile User Analytics: analyzes user behaviors under varying network and device conditions.

 

Goals

  • Create a new policy app from Luna.
  • Download the SDK and include it in your app.
  • Register the SDK and start using it.

 

Prerequisites

You must be using Akamai Ion to use download this SDK. If you are not an Ion customer, please reach out to us at mapsdk@akamai.com.

 

Installation for Android

 

Step 1: Create a New Policy App from Luna

Before you can download the SDK, there are a few configuration steps in Luna, and then you generate the SDK key and download the SDK.

  1. Start by navigating to the Luna Control Center. Under the Configure tab, click Mobile App Perf SDK. This will take you to the page where you can view the existing policies, and create new ones as well.
    Note: if you don’t see this tab, please reach out to your Akamai Account team who can activate this for you.
  2. Add a new App:

    ● Click on Add new App. On the New App page, fill in details about the app, for example, its name, its package id or its bundle id.

    ● Turn Network Quality Detection to On and fill in the domain that your app uses (for example api.foo.com or images.foo.com). Leave the other settings as they are for now.

    ● Click Prepositioning and then turn Prepositioning to On.

    ● Fill in the field for your Google GCM Key. These keys allow Akamai to push changes to the devices that use the SDK.

    ● Click Save Changes, to download the SDK and generate the license key.
     

  3. To use the SDK in the app, you’ll need to initialize it with a license key in your app code. To get the license key, select Copy SDK License Key. This key will be common to both the iOS and Android apps for the given package or build ID name. You’ll use this key in a minute.
  4. Now, click the Actions drop-down list and select the SDK for Android. You’ll download a zip file that contains the SDK itself, integration guides, and sample codes.

 

Step 2: Integrate the SDK 

To integrate the SDK with your Android app, you’ll need to add the SDK to your build.gradle file, declare required dependencies, and then add the Meta Data and Content Provider required by the SDK.

  1. Open up the .zip file that you downloaded.

  2. Copy the .jar file to the apps/libs folder in your Android app’s project files, and configure your build.gradle to compile it, along with the dependencies

  3. The MAP SDK has a dependency on Google Play Services, so don’t forget to include them in your project by adding them to your build.gradle file of your app (not project):he MAP SDK in your build.gradle file. The MAP SDK has a dependency on Google Play Services, and the Support Library, so don’t forget to include them in your project by adding them to your build.gradle file of your app (not project):

     dependencies {
         compile'com.google.android.gms:play-services-base:9.4.0
         compile'com.google.android.gms:play-services-gcm:9.4.0'
         compile'com.akamai.android:map-sdk:<version>@aar'
    }

  4. In the AndroidManifest.xml file of your app, declare the Content Provider that the SDK requires, along with the meta-data pointing to the configuration file:
     <provide
         android:name="com.akamai.android.sdk.db.AnaContentProvider"
         android:authorities="YOUR_PACKAGE_NAMEW.AnaContentProvider">
    </provider>

 

 

Step 3: Initializing and Registering the SDK

  1. Initialize the SDK in a base or root activity by calling the following method:

     VocService.createVocService(this); 

    If your app structure is such where a base class extends Application class, and all the further activities extend from this base class, then initialize this SDK in the base class.

  2. Register the SDK
    Once you figure what segments you need to register with, use the following code to register with them:

     VocService vocService = VocService.createVocService(getApplicationContext());
    VocRegistrationStatus status = vocService.getRegistrationStatus();
    if (!status.isActive()) {
      String[] segments = {"First", "Second", "Third"}
      VocRegistrationInfo regInfo = new VocRegistrationInfo("<Your-SDK-License-Key>", segments);
      vocService.register(regInfo, new VocService.VocAysncResponseHandler(new Handler()) {
         @Override
         public void onSuccess() {
           // do success related tasks
         }
         @Override
         public void onFailure(String s) {
            // do failure related tasks
         }
      });
    }

    After this step, you should be able to use the various SDK methods. For detailed documentation, refer to the Integration guide provided with the SDK .zip file.

You’re now ready to start writing code, using the MAP SDK in your Android apps.

 

Installation for iOS

 

Step 1: Create a New Policy App from Luna

Before you can download the SDK, there are a few configuration steps in Luna, and then you generate the SDK key and download the SDK.

  1. Start by navigating to the Luna Control Center. Under the Configure tab, click Mobile App Perf SDK. This will take you to the page where you can view the existing policies, and create new ones as well.
    Note: if you don’t see this tab, please reach out to your Akamai Account team who can activate this for you.
  2. Add a new App:

    ● Click on Add new App. On the New App page, fill in details about the app, for example, its name, its package id or its bundle id.

    ● Turn Network Quality Detection to On and fill in the domain that your app uses (for example api.foo.com or images.foo.com). Leave the other settings as they are for now.

    ● Click Prepositioning and then turn Prepositioning to On.

    ● Fill in the field for your Google GCM Key. These keys allow Akamai to push changes to the devices that use the SDK.

    ● Click Save Changes, to download the SDK and generate the license key.
     

  3. To use the SDK in the app, you’ll need to initialize it with a license key in your app code. To get the license key, select Copy SDK License Key. This key will be common to both the iOS and Android apps for the given package or build ID name. You’ll use this key in a minute.
  4. Now, click the Actions drop-down list and select the SDK for iOS. You’ll download a zip file that contains the SDK itself, integration guides, and sample codes.

 

Step 2: Integrate the SDK 

  1. To integrate the SDK with your iOS app, you’ll need to add the SDK as a project and rename it to voc_sdk.
  2.  Copy the framework from ~/myproject/voc_sdk/iphoneos/VocSdk.framework into your project folder at ~/myproject/VocSdk.framework. This allows Xcode to recognize the framework before the first build. Each build afterward will copy the correct framework (either device or simulator) into place using the copy_vocsdk build phase script.
  3. Add VocSdk.framework to your project file.
  4. Link the SDK as an embedded library to your project. Embedded libraries can be found in the General tab when you click on the project name in the files navigator.
  5. To ensure that the right framework is built for the right target (Device or Simulator), you have to add a build phase.

    ● In project settings, navigate to Build Phases and add a new build phase.

    ● Rearrange the build phase settings so that it is after the target dependencies. You could optionally rename it to copy_vocsdk for better understanding.

    ● Now expand the setting by clicking on the arrow.

    ● Leave the default shell setting of /bin/sh.

    ● Add the following in script area:

     ./voc_sdk/copy_vocsdk.sh “${PROJECT_DIR}/voc_sdk” 

    Note: “${PROJECT_DIR}/voc_sdk signifies the location of the /iphoneos and /iphonesimulator folders from the distribution archive. This script ensures that the correct framework will be available in the project folder linked to the xcode project file.
     

  6. Compile the source code and make sure that there are no errors.

 

Step 3: Initializing and Registering the SDK

  1. Initialize the SDK by using:

     VocServiceFactory createAkaWebAccelerationWithDelegate:delegateQueue:options:error: 
  2. Since the acceleration needs to available to the app as soon as it starts up, you must initialize and register in the application delegate method:
     application:didFinishLaunchingWithOptions: 
  3. The code snippet below demonstrates the SDK initialization and makes the appdelegate object to delegate the handling of all the callbacks from the SDK.
     ( BOOL ) application :( UIApplication *) application didFinishLaunchingWithOptions :( NSDictionary *) launchOptions
    {
      NSError * error = nil ;
      self . akaService = [ VocServiceFactory createAkaWebAcceleratorWithDelegate : self
      delegateQueue :[ NSOperationQueue mainQueue ] options : nil
      error :& error ];
      if (! self . akaService ) {
         // error handling - could not start service
         return NO ; }
         // app initialized
         return YES ;
    }

 

Step 4: Registering the SDK

  1. To activate the VOCService, you need to register the SDK with a licence key and an array of segments. The key plays a significant role in mapping the app to the pre-positioned content, usage statistics, and other related SDK capabilities.

    This method returns an object of VocService. The VocService contains an instance called state which indicates whether the registration succeeded for the particular device. You should check with the state property each time before commencing registration.

     NSArray *segments = [@"First",@"Second",@"Third"];
    [appDelegate . akaService registerWithLicense : sdkLicense
    segments : segments completion :^( NSError * __nullable error ) {
      if ( error ) { // handle failed registration };
    }];

 

 

Creating and Managing Segments

 

Understanding Segments and Segment Subscriptions

It is important to understand Segments and how to subscribe the app to the segments. The content prepositioning is a vital feature of the SDK. The contents are ingested during the content ingest phase and the SDK prepositions the content making it available instantly to the user.

 

Segments

A segment is a unique string which represents a particular category of content. For example, an e-commerce app could have segments for “Winter clothing”, “Swimsuits” etc., Your mobile app can subscribe to one or more segments, which can be pre-positioned using the Ingest API.

Once You decide which app users need to fall under what categories, you can program the app to subscribe to the corresponding segments. So in our earlier example, an app could subscribe to two segments “Winter Clothing” & “Swimsuits” and have that content prepositioned.

 

Subscribing to Segments

Apps can subscribe to segments by specifying the segment strings during the registration phase. You can see in the example code above for iOS and Android, how the code segments are specifying the segments while registering.

 

Sending Data to Segments Using the Ingest API

Once the apps start registering to the correct segments as per the category they fall on, in a certain device, you can use Ingest API to send, or ingest content to those segments, to specify what images should be prepositioned for what segments.

Free Trial

If you are an existing Ion Premier or Ion Media Advanced customer, you can add them to your contract today.

Akamai Marketplace  Email us to add Ion