Live Update


Overview

The Live Update feature in PMF provides a simple way to define and serve different configurations for each users of an application. It includes a component in the PMF Operations Console for defining the structure of the configuration as well as the values of the configuration. Also provided is a client SDK (available for Android and iOS native and for Cordova applications) for consuming the configuration.

Common Use Cases

  • Release trains and feature flipping
  • A/B testing

Jump to:

Live Update Architecture

The following system components function together in order to provide the Live Update functionality.

  • Live Update adapter: an adapter which provides:
  • Application schema management
  • Serving configurations to applications
  • Client-side SDK: the Live Update SDK is used to retrieve and access configuration elements such as features and properties from the PMF.
  • PMF Operations Console: used for configuring the Live Update adapter and settings.
  • Configuration Service: Internal. Provides configuration management services for the Live Update adapter.

Adding Live Update to PMF

By default, Live Update Settings in the PMF Operations Console is hidden. To enable, the provided Live Update adapter needs to be deployed.

  1. Open the PMF Operations Console. From the sidebar navigation click on Download Center → Tools tab.
  2. Download and deploy the Live Update adapter.

Once deployed, the Live Update Settings screen is then revealed for each registered application.

Deploy live update

Configuring Application Security

In order to allow integration with Live Update, a scope element is required. Without it, the adapter will reject requests from client applications.

Load the PMF Operations Console and click on [your application] → Security tab → Scope-Elements Mapping. Click New and enter the scope element configuration-user-login. Then, click Add.

You can also map the scope element to a security check in case you’re using one in your application.

Learn more about the PMF security framework

Add a scope mapping

Schema

One tab is available in the Live Update Settings screen.

What is Schema

A schema is where features and properties are defined.

  • Using “features” you can define configurable application features and set their default value.
  • Using “properties” you can define configurable application properties and set their default value.

Adding Schema

Before adding a schema for an applicaiton, the developer or product management team need to reach a decision about several aspects:

  • The set of features to utilize Live Update for as well as their default state
  • The set of configurable string properties and their default value


Once the parameters are decided upon, Schema features & properties can be added.
To add, click New and provide the requested values.

  • Feature: A feature determines if some part of the application functionality is enabled or disabled. When defining a feature in the schema of an application the following elements should be provided:
    • id – A unique feature identifier. String, Non-editable.
    • name - A descriptive name of the feature. String, Editable.
    • description – A short description of the feature. String, Editable.
  • Property: A property is a key:value entity that can be used to customize applications. When defining a property in the schema of an application the following elements should be provided:
    • id – A unique property identifier. String, Non-editable.
    • name - A descriptive name of a property. String, Editable.
    • description – A short description of the property. String, Editable.

Define Schema features and properties with default values

Add schema feature and property

Adding Live Update SDK to applications

The Live Update SDK provides developers with API to query runtime configuration features and properties that were previously defined in the Live Update Settings screen of the registered application in the PMF Operations Console.

For Cordova.

For Android.

For iOS.

Adding the Cordova plugin

In your Cordova application folder run:

cordova plugin add cordova-plugin-mfp-liveupdate

Adding the iOS SDK

  1. Edit your application’s podfile by adding the PersistentMobileFoundationLiveUpdate pod.
    For example:

    use_frameworks!
    
    target 'your-Xcode-project-target' do
       pod 'PersistentMobileFoundation'
       pod 'PersistentMobileFoundationLiveUpdate'
    end
    
  2. From a command-line window, nagivate to the Xcode project’s root folder and run the commmand: pod install.

Adding the Android SDK

To add the PMF SDK, first download the SDK .zip file from the PMF Operations Console → Download Center → SDKs tab. After completing the above steps, follow the below as well.

  • Extract the downloaded .zip file and place the relevant aar files to the app\libs folder.
  • Add the following to the dependencies closure:

      implementation fileTree(include: ['*.aar'], dir: 'libs')
    
  • Add the following to the repositories closure:
      repositories {
          flatDir {
              dirs 'libs'
          }
      }
    
      > If a Gradle Sync request appears, accept it.
    

Using the Live Update SDK

There are several approaches to using the Live Update SDK.

With the Live Update configuration retrieved, the applicative logic and the application flow can be based on the state of features and properties. For example, if today is a national holiday, introduce a new marketing promotion in the application.

Cordova Resolver

var input = { params : { 'paramKey': 'paramValue'} ,useClientCache : true };                                                                                                    
LiveUpdateManager.obtainConfiguration(input,function(configuration) {
        // do something with configration (JSON) object, for example:
        // console.log(configuration.properties.property-name);                                                                                                             // console.log(configuration.data.features.feature-name);                                                                                                        
    } ,
    function(err) {
        if (err) {
           alert('liveupdate error:'+err);
        }
  });

iOS

LiveUpdateManager.sharedInstance.obtainConfiguration(["paramKey":"paramValue"], completionHandler: { (configuration, error) in
  if error == nil {
    print (configuration?.getProperty("property-name"))
    print (configuration?.isFeatureEnabled("feature-name"))
  } else {
    print (error)
  }
})

Android

Map <String,String> params = new HashMap<>();
params.put("paramKey", "paramValue");

LiveUpdateManager.getInstance().obtainConfiguration(params , new ConfigurationListener() {

    @Override
    public void onSuccess(final Configuration configuration) {
        Log.i("LiveUpdateDemo", configuration.getProperty("property-name"));
        Log.i("LiveUpdateDemo", configuration.isFeatureEnabled("feature-name").toString());
    }

    @Override
    public void onFailure(WLFailResponse wlFailResponse) {
        Log.e("LiveUpdateDemo", wlFailResponse.getErrorMsg());
    }
});

Adapter implementation

The arguments that are provided by the application using the Live Update client SDK are then passed to the Live Update adapter. This is done automatically by the Live Update adapter without any developer action needed.

Advanced Topics

Import/Export

Once a schmea have been defined, the system administrator can export and import them to other server instances.

Export schema

curl --user admin:admin http://localhost:9080/mfpadmin/management-apis/2.0/runtimes/mfp/admin-plugins/liveUpdateAdapter/com.sample.HelloLiveUpdate/schema > schema.txt

Import schema

curl -X PUT -d @schema.txt --user admin:admin -H "Content-Type:application/json" http://localhost:9080/mfpadmin/management-apis/2.0/runtimes/mfp/admin-plugins/liveUpdateAdapter/com.sample.HelloLiveUpdate/schema
  • Replace “admin:admin” with your own (default is “admin”)
  • Replace “localhost” and the port number with your own if needed
  • Replace the application identifier “com.sample.HelloLiveUpdate” with your own application’s.

Caching

Caching is enabled by default in order to avoid network latency. This means that updates may not take place immediately.
Caching can be disabled if more frequent updates are required.

Cache expiration

The expirationPeriod value that is defined in Adapters → Live Update adapter dictates the length of time until the caching expires.

Image of the sample application

Sample application

In the sample application you select a country flag and using Live Update the app then outputs text in language that corresponds to the selected country. If enabling the map feature and providing the map, a map of the corresponding country will be displayed.

Click to download the Xcode project.
Click to download the Android Studio project.

Last modified on