All Products
Search
Document Center

Mobile Platform as a Service:Client Sends Notification to Card

Last Updated:Nov 24, 2025

Register a notification listener on the card side using JSAPI

Import dependencies

const mp = requireModule("mpaas_jsapi");

postNotification

Sends a notification.

mp.postNotification(
  {
    name:'TEST_EVENT',
    data: {
      hello: 'hello world'
    }
  },
  res=>{
    
  }
);

addNotifyListener

Registers a notification listener in the didAppear lifecycle.

   didAppear() {
        mp.addNotifyListener(
            {
                name: 'TEST_EVENT'
            },
            res => {
                this.clientToCube(res)
            }
        )
    },

removeNotifyListener

Removes a notification listener.

didDisappear() {
        mp.removeNotifyListener(
            {
                name: 'TEST_EVENT'
            },
            res => {
                console.info(JSON.stringify(res))
            }
        )
    },
Note

The client performs verification, and the notification listener will be automatically released after calling MPCube.recycleCard.

Client sends notification

Android

MPCube.postNotification(String notifyName,JSONObject notifyParams);

iOS

[[NSNotificationCenter defaultCenter] postNotificationName:notifyName object:nil userInfo:notifyParams];