Mobile Application Performance SDK

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.

Features of the SDK include:

  • Network Quality Awareness API which detects current mobile network conditions and informs the app, the Edge, and the origin so that optimizations can be made. For example, Akamai Adaptive Image Compression is automatically tuned for current mobile network conditions.

  • Content Prepositioning which intelligently pushes content to mobile devices enabling instant app view load times and offline access to content.

  • SureRoute for Cellular which finds the ideal path through the cellular network to the Akamai Edge for your most important latency sensitive requests.

  • Real user and device insights, including custom metrics, help developers tune mobile experiences over time. Available performance metrics such as time to first byte and total download time can be filtered by device type, carrier, connection type, app version, and more allowing you to pinpoint performance challenges and eliminate them.

Getting Started with the MAP SDK for Android

Integrating and setting up the MAP SDK is a three-step process:

  1. Create a new policy app from Luna.

  2. Download the SDK and include it in your app.

  3. Initialize the SDK and start using it.

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 Portal (control.akamai.com), and under the Configure tab, click Mobile App Perf SDK. This takes you to the page where you can create and view policies.

    Note: if you don’t see this tab, please reach out to your Akamai Account team who can activate this for you.

  2. Click Add a New App.

  3. On the New App page, fill in all the details about the app. For example, its name, its package ID or bundle ID. Refer to points 1 and 2 in the following figure. To create a new app, you need to fill out these fields.

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

  5. Click Prepositioning and then turn Prepositioning to On.

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

  7. Click Save Changes, which saves your settings and allows you to download the SDKs and generate the license key.

  8. 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.

Step 2: Download the SDK and Include In Your App

To integrate the SDK with your Android app, you’ll need to add the SDK .jar to your dependencies, declare required dependencies, and then add the 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):

        
        dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            compile 'com.google.android.gms:play-services-base:9.4.0'
            compile 'com.google.android.gms:play-services-gcm:9.4.0'
            compile (name:'voc-sdk-', ext:'aar')
        }
        
  4. In the AndroidManifest.xml file of your app, declare the Content Provider that the SDK requires:

        
        <provider
            android:name="com.akamai.android.sdk.db.AnaContentProvider"
            android:authorities="YOUR_PACKAGE_NAMEW.AnaContentProvider">
        </provider>
        

Step 3: Initializing and Registering the SDK

Initialize the SDK

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.

Registering 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.

Getting Started with the MAP SDK for iOS

Integrating and setting up the MAP SDK is a three-step process:

  1. Create a new policy app from Luna.

  2. Download the SDK and include it in your app.

  3. Initialize the SDK and start using it.

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 Portal (control.akamai.com), and under the Configure tab, click Mobile App Perf SDK. This takes you to the page where you can create and view policies.

    Note: if you don’t see this tab, please reach out to your Akamai Account team who can activate this for you.

  2. Click Add a New App.

  3. On the New App page, fill in all the details about the app. For example, its name, its package ID or bundle ID. Refer to points 1 and 2 in the following figure. To create a new app, you need to fill out these fields.

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

  5. Click Prepositioning and then turn Prepositioning to On.

  6. Fill in the field for Apple Dev APNS key. These keys allow Akamai to push changes to the devices that use the SDK.

  7. Click Save Changes, which saves your settings and allows you to download the SDKs and generate the license key.

  8. 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.

Step 2: Download the SDK and Include In Your App

  1. To integrate the SDK with your iOS app, unzip the MAP SDK .zip file into your project folder 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 copies 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.

To ensure that the right framework is built for the right target (Device or Simulator), you have to add a build phase.

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

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

  3. Now expand the setting by clicking on the arrow.

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

  5. Add the following in script area:

        
        ./voc_sdk/copy_vocsdk.sh "${PROJECT_DIR}/voc_sdk"
        

Note that "${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.

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

Step 3: Initializing and Registering the SDK

Initialize the SDK

Initialize the SDK by using:

    
    VocServiceFactory createAkaWebAccelerationWithDelegate:delegateQueue:options:error:
    

Since the acceleration needs to available to the app as soon as it starts up, initialize and register in the application delegate method:

    
    application:didFinishLaunchingWithOptions:
    

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 ;
    }
    
Registering the SDK

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 prepositioned 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

To create audience segments, you use the Ingest API. For more information, contact your Akamai representative who will help you with this.

Downloads

Interested in a free trial download of Akamai’s Mobile Application Performance SDK?

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

If you are not an Ion Customer please reach out to us at mapsdk@akamai.com

Additional Resources

E-Book: Are You Meeting Today's Mobile Mandate?

Solution Brief: Akamai Mobile Performance Solutions

Akamai White Paper: Unlocking Mobile Application Performance