All Products
Search
Document Center

Mobile Platform as a Service:Unregister custom events

Last Updated:Jan 22, 2026

If the default APIs and events do not meet your needs when you develop mPaaS Mini Programs, you can create custom extensions. You can also unregister these custom APIs and events when they are no longer needed.

Call a native custom API from a Mini Program

Original procedure:

  1. Customize and register the API on the client.

    For more information about how to register your custom API, see Custom JSAPI.

  2. Call the API from the Mini Program.

     const call = my.call('tinyToNative', {
       param1: 'p1aaa',
       param2: 'p2bbb'
     }, (result) => {
       console.log(result);
       my.showToast({
         type: 'none',
         content: result.message,
         duration: 3000,
       });
     })

The following describes the method for canceling the registration:

    // Unregister
    call.remove();
    call = undefined;

Send a custom event from a native application to a Mini Program

Original procedure:

  1. Register the event in the Mini Program:

     const on = my.on('www',()=>{
           my.alert({
             title: '1212',
             content: '123',
             buttonText: '123123',
             success: () => {
             },
             fail: () => {
             },
             complete: () => {
             }
           });
     })
  2. Send the event from the client.

    Obtain the viewController of the current Mini Program page. Then, call the callHandler method to send the event.

    [self callHandler:@"nativeToTiny" data:@{@"key":@"value"} responseCallback:^(id responseData) {
    }];

Follow this method to cancel the registration:

    on.remove();
    on = undefined;

Parameters:

Parameter

Description

handlerName

The name of the event that the Mini Program listens for.

data

The parameters passed from the client to the Mini Program.

callback

The callback block that is processed after the Mini Program completes execution.