All Products
Search
Document Center

Mobile Platform as a Service:Integrate with Android

Last Updated:Jan 19, 2026

This topic describes how to integrate the MSS component with an Android client.

Note

As of June 28, 2020, mPaaS no longer maintains the 10.1.32 baseline. Use the 10.1.68 or 10.1.60 baseline. To upgrade your baseline version, see mPaaS 10.1.68 Upgrade Guide or mPaaS 10.1.60 Upgrade Guide.

The MSS component supports two integration methods: native AAR-based integration and component-based integration.

The integration procedure consists of two steps:

  1. Add the SDK

  2. Use the SDK

Prerequisites

You have integrated your project with mPaaS.

Add the SDK

Native AAR-based integration

Use Component Management (AAR) to install the SYNC component in your project. For more information, see AAR component management.

Component-based integration

In the Portal and Bundle projects, use Component Management to install the SYNC component.

For more information, see Manage component dependencies > Add or remove component dependencies.

Use the SDK

In baselines 10.1.32 and later, the MPSync class in the mPaaS middleware layer encapsulates all APIs of the MSS component. You can use the MPSync object to access all MSS features.

The following table provides a quick overview of the MSS APIs. For more information about the APIs, see Android API reference.

API

Description

setup(Application application)

Initializes the basic services that MSS depends on. This method must be called before the initialize method. This method is available only in baselines 10.1.60 and later.

initialize(Context context)

Initializes the API and the MSS service.

appToForeground()

Notifies the client SDK that the app is started to establish a network connection with the server. Call this method each time the app is brought to the foreground.

appToBackground()

Notifies the client SDK that the app is sent to the background to disconnect from the server. Call this method each time the app is sent to the background.

updateUserInfo(String sessionId)

Call this method when the logon information such as userId or sessionId changes. This method must be called at least once.

clearUserInfo()

Logs out the user.

registerBiz(String bizType, ISyncCallback syncCallback)

Registers a callback to receive business data. After the pushed data is received, the client SDK calls the syncCallback implementation class.

unregisterBiz(String bizType)

Unregisters the specified synchronization configuration. After the configuration is unregistered, the client SDK no longer calls the syncCallback implementation class when pushed data is received.

reportMsgReceived(SyncMessage syncMessag)

After data is received in the syncCallback implementation class, call this API to notify the MSS server that the data is successfully received. If the server does not receive a reportMsgReceived call, it retries to deliver the data. After six retries, the data is permanently deleted.

isConnected()

Checks whether the MSS service is running as expected.

Code sample

This sample is developed using the SDK of baseline 10.1.32. In the sample application, a button is configured to obtain the device ID when tapped. The console then uses the device ID to push synchronization data to the device. The synchronization identity is bizType.

Note

This sample only demonstrates how to call the MSS APIs and is not a best practice for MSS. Download the best practice code for the MSS component from the Get code sample page.

    public void button1Clicked(View view)
    {
        // Use the getUtdid method to obtain the device ID.
        String utdid =UTDevice.getUtdid(MainActivity.this);
        // Print the MSS data in Logcat.
        Log.e("=========",utdid);
        // Initialize the API and the MSS service.
        MPSync.initialize(MainActivity.this);
        // Register a callback to receive business data. After the pushed data is received, the syncCallback is called.
        MPSync.registerBiz("bizType",new SyncCallBackImpl());
        // Establish a network connection with the server.
        MPSync.appToForeground();

    }

    public class SyncCallBackImpl implements ISyncCallback
    {
        @Override
        public void onReceiveMessage(SyncMessage syncMessage) {
            // Print the MSS data in Logcat.
            Log.e("=========",syncMessage.msgData);
            // Notify the MSS server that the data is successfully received.
            MPSync.reportMsgReceived(syncMessage);
        }
    }

TLS support

To enable TLS connections on ports other than 443, add the metadata mss_use_tls to the manifest file and set its value to YES.

image.png

Note

Connections on port 443 use TLS by default.

What to do next

Integrate with the server-side