All Products
Search
Document Center

Mobile Platform as a Service:Quick start

Last Updated:Jan 30, 2026

The gateway connects clients to the server-side and enables them to access backend service interfaces.

The gateway lets you:

  • Encapsulate communication between the client and the server-side using a dynamic proxy.

  • Automatically generate and export code from the server-side for the client to use if they share the same interface definitions.

  • Handle RpcException errors uniformly with features such as dialog boxes and toast messages.

Mobile Gateway supports two integration methods: native AAR and component-based (Portal & Bundle).

Prerequisites

Add the SDK

Native AAR method

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

Component-based (Portal & Bundle) method

In your Portal and Bundle projects, use Component Management to install the Mobile Gateway component. For more information, see the component-based integration process.

Initialize mPaaS

If you use the native AAR integration method, initialize mPaaS.

public class MyApplication extends Application {
    
    @Override
    public void onCreate() {
        super.onCreate();
        // Initialize mPaaS
        MP.init(this);    
    }
}

For more information, see Initialize mPaaS.

Generate RPC code

After your app connects to the backend service in the Mobile Gateway console, go to the mPaaS console. In the navigation pane on the left, choose Mobile Gateway > API Management > Generate Code to download the RPC code for the client. For more information, see Register an API.

The downloaded RPC code has the following structure. It includes the RPC configuration, request model, and response model.RPC

Call an RPC

The client initiates an RPC call. The following code shows an example:

// Get the client instance
RpcDemoClient client = MPRpc.getRpcProxy(RpcDemoClient.class);
// Set the request
GetIdGetReq req = new GetIdGetReq();
req.id = "123";
req.age = 14;
req.isMale = true;
// Initiate the RPC request
try {
    String response = client.getIdGet(req);
} catch (RpcException e) {
    // Handle RPC request exceptions
    Log.i("RpcException", "code: " + e.getCode() + " msg: " + e.getMsg());
}

RPC call exceptions are thrown as RpcException. Handle these exceptions based on the code value in the RpcException. For more information about error codes, see Gateway result codes.

Related links