Skip to content

01. Getting Started

Hadi Tavakoli edited this page Oct 12, 2018 · 2 revisions

The Config File

The first thing you should do is to include the config ADBMobileConfig.json file you must have downloaded from your Adobe Mobile Services UI. It is important to copy this file to File.applicationStorageDirectory.resolvePath("ADBMobileConfig.json"); So the ANE will be able to read its content correctly.

// config file should be in File.applicationStorageDirectory

// If you are bundling the config file in your app, it will be in File.applicationDirectory
var f:File = File.applicationDirectory.resolvePath("ADBMobileConfig.json");

// You should copy it to File.applicationStorageDirectory
var configFile:File = File.applicationStorageDirectory.resolvePath("ADBMobileConfig.json");

f.copyTo(configFile);

The ANE Implementation

Implementing this ANE is just like adding any other ANE to your project. If you are new to adding ANEs, do watch these videos: https://www.youtube.com/watch?v=Oubsb_3F3ec&list=PL_mmSjScdnxnSDTMYb1iDX4LemhIJrt1O

<extensionID>com.myflashlab.air.extensions.ADBMobile</extensionID>

Every ANE, may have some dependencies and extra setup. This information is included in all our ANEs. Check out the ANE extension.xml file and scroll down to see the <!-- ANE SETUP line. Use this information to know how you must setup your app's manifest .xml file. If you don't know how to use this information to implement the ANE dependencies/configuration, consider one of the following solutions:

  • Consider using the ANELAB Software. This Software will add ANEs to your app automatically to save your time.
  • Read this post and learn how <!-- ANE SETUP is formatted and start doing things manually.

ANELAB

Initialization & Lifecycle

Considering that you have copied the config json file to File.applicationStorageDirectory, you must pass it to the init method like this.

// call init and pass the config File to it.
ADBMobile.init(configFile);

On Android, you must notify the ANE when app starts or goes to background each time, on the iOS side however, this is managed automatically by the SDK.

/*
    Right after the ANE is initialized, call "collectLifecycleData"

    iOS will send lifecycle information with or without calling "collectLifecycleData"; and
    this method is only a way to initiate lifecycle earlier in the application's launch sequence.
*/
ADBMobile.collectLifecycleData();

On Android, listen for Event.ACTIVATE and Event.DEACTIVATE and when app goes to background or when it closes, call pauseCollectingLifecycleData()

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate);
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate);

private static function handleActivate(e:Event):void
{
    if(OverrideAir.os == OverrideAir.ANDROID)
    {
        if(ADBMobile.isInitialized)
        {
            // this happens on iOS automatically. so we should call this on Android
            ADBMobile.collectLifecycleData();
        }
    }
}

private static function handleDeactivate(e:Event):void
{
    if(OverrideAir.os == OverrideAir.ANDROID)
    {
        // this happens on iOS automatically. so we should pause only on Android
        ADBMobile.pauseCollectingLifecycleData();
    }
}

The ContextData

Different methods of the ANE, are expecting an optional ContextData object. You can use it to pass any context data you like based on your apps requirements. below is a sample on how to create a ContextData instance and pass it to the collectLifecycleData method.

var ctx:ContextData = new ContextData();
ctx.put("myapp.category", "Game");
// ctx.put("key", "value");
// ctx.put("key3", "value3");
ADBMobile.collectLifecycleData(ctx);

Find asdoc for this ANE here: https://myflashlab.github.io/asdoc/com/myflashlab/air/extensions/adobeMobile/package-detail.html

You can’t perform that action at this time.