All Products
Search
Document Center

SuperApp:Communication

Last Updated:Jun 02, 2026

Covers the WVStandardEventCenter JavaScript API, which lets H5 pages send events to a native client. This is a one-way channel: H5 to native only. Intended for developers of H5 applications and mini programs.

WVStandardEventCenter.postNotificationToNative

Sends a named event from an H5 page to the native client. The event name is arbitrary but must be agreed on between the H5 team and the native team before use.

Listen for events on iOS

Use NSNotificationCenter to subscribe to the event by name.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myEventListener) name:eventName object:nil]

- (void)myEventListener:(NSNotification *)notification {
        // Retrieve event parameters from notification.userInfo.
}

Listen for events on Android

Implement WVEventListener and register it with WVEventService. All events are dispatched to onEvent; filter by WVEventId.H5TONATIVE_EVENT to handle events sent from H5.

@import android.taobao.windvane.service;
@import android.taobao.windvane.standardmodal

// Implement a listener that handles all WindVane events.
public class JsEventListener implements WVEventListener {
        @Override
        public WVEventResult onEvent(int id, WVEventContext ctx, Object... obj) {
                // Filter for events sent from H5.
                if (id == WVEventId.H5TONATIVE_EVENT) {
                        if (obj[0] instanceof String) {
                                String params = (String)obj[0];
                                // params is a JSON string containing the event name and parameters — deserialize before use.
                        }
                }
                return null;
        }
}

// Register the listener to start receiving events.
WVEventService.getInstance().addEventListener(new JsEventListener());

Input parameters

  • [string]event: The name of the event to send. Must match the name the native team listens for.

  • [object]param: (Optional) Additional data to send with the event.

Callback parameters

Only one callback fires per call — either success or failure, never both.

  • success: Called without arguments when the native client receives the event.

  • failure: Called with an error object if the event cannot be delivered.

    var params = {
            event: 'eventName',
            param: {
                    // Event parameters.
            }
    };
    window.WindVane.call('WVStandardEventCenter','postNotificationToNative', params, function(e) {
            alert('success');
    }, function(e) {
            alert('failure: ' + JSON.stringify(e));
    });