Skip to content

Host methods

Call custom methods of the host app to implement business extensions.

const result = await SuperSDK.callHostMethod('getUserInfo', { id: '123' });
console.log(result);

Parameter Description:

ParameterTypeDescription
methodNamestringMethod Name
paramsobjectParameter Object

Note: This method has no timeout limit; the Promise will wait indefinitely for the host app to return a result. If timeout control is required, implement it at the business layer.

The host app must implement the HostMethodService interface to register custom methods.

Report events to the SDK’s built-in analytics (implemented via SReporter).

await SuperSDK.reportEvent('page_view', { page: 'home', duration: 1200 });

Parameter Description:

ParameterTypeDescription
eventNamestringEvent Name
paramsobjectEvent Parameters (Optional)

Open browser page (SDK built-in implementation; Android uses the system browser, iOS uses SFSafariViewController).

SuperSDK.openBrowser('https://example.com', 'Example page');

Parameter Description:

ParameterTypeDescription
urlstringURL to open
titlestringPage Title

Display Toast notification (SDK built-in implementation; Android uses system Toast, iOS uses custom overlay).

SuperSDK.showToast('Success');

Parameter Description:

ParameterTypeDescription
messagestringMessage Content

reportEvent, showToast, and openBrowser are all built-in SDK implementations and do not require additional handling by the host app.

Set common tracking parameters. After setting, all subsequent reportEvent reports from this WebView will automatically include the common parameters (commonly used to uniformly inject context such as page source or AB experiment group).

SuperSDK.addEventCommonParam('source', 'home_banner');
SuperSDK.addEventCommonParam('ab_group', 'B');
// All subsequent reportEvent calls will include source and ab_group.

Parameter Description:

ParameterTypeDescription
keystringCommon Parameter Keys
valuestringCommon parameter values (non-strings are converted to strings, null/undefined are converted to empty strings)

Synchronous method, no return value. In non-end environments (without appbridge), it is a no-op and throws no errors.

Submit a user feedback. In the client environment, Native completes spid / env / device_id / platform / app_version / sdk_version / os_version / device_model via JSB and reports to POST /superapi/v2/feedback. In non-client environments (where baseUrl(s) + spid are provided via init/initFallback), JSSDK directly performs fetch. The server records the submission time and user IP. The console allows viewing, searching, and marking the processing status under “Business Operations → User Feedback” by project and environment.

const { feedbackId } = await SuperSDK.submitFeedback({
scene: 'settings', // Required · Feedback Scenario
subScene: 'about', // Optional · Sub-scenario
title: 'Crash opening Settings', // Required
content: 'The app consistently crashes about one second after opening Settings, Pixel 8 / Android 14', // Required
userId: 'u_123456', // Optional · Business User ID (SDK does not maintain user identity; caller must pass it per request)
extra: { page: 'settings', build: 42 } // Optional · Additional Information
});

Parameter Description:

ParameterTypeRequiredDescription
scenestring✓Feedback scenario, ≤64 characters
subScenestringSub-scenario, ≤64 characters
titlestring✓Title, ≤200 characters
contentstring✓Feedback content, ≤5000 characters
userIdstringBusiness user ID, ≤128 characters; if not provided, the console user_id is empty.
extraobjectAdditional information, JSON object, serialized size ≤4KB

Return value: Promise<{ feedbackId: number }> — Server-side feedback record ID.

Error:

ScenarioIn-app (JSB)web
Invalid parameter (length/type)reject Error('INVALID_PARAMS'), with err.detail containing the reasonSuperSDKError INVALID_ARGUMENT
Not initialized-NOT_INITIALIZED
Server-side business rejectionField rejected by server → reject Error('INVALID_ARGUMENT'); project/environment does not exist → reject Error('BRIDGE_ERROR') (Native normalizes code via JSB registry, err.detail contains sanitized message).INVALID_ARGUMENT, err.nativeCode is the server-side code (INVALID_REQUEST / NOT_FOUND …)
Trigger rate limiting (10 requests per minute per IP · 600 requests per minute per project)reject Error('RATE_LIMITED')RATE_LIMITED
Network/Timeoutreject Error('NETWORK_ERROR' / 'TIMEOUT')NETWORK_ERROR / TIMEOUT / UNAVAILABLE (automatic rotation of baseUrls)
Native version is outdated (no such JSB).reject Error('SDK_TOO_OLD')-

Field length is determined by server-side validation (JSSDK local validation is merely a mirror of the same rule); all strings will be trimmed. The submission is not idempotent; do not retry the same content repeatedly on the business side.

Set status bar dark/light mode.

// Dark background page: Status bar icons are displayed in white.
SuperSDK.setStatusBarDarkMode(true);
// Light background page: Status bar icons are displayed in black.
SuperSDK.setStatusBarDarkMode(false);

Parameter Description:

ParameterTypeDescription
isDarkbooleantrue=dark background (status bar icons are white); false=light background (icons are black)

Synchronous method, no return value. In non-end environments, it is a no-op and throws no errors.

Invoke the soft keyboard.

SuperSDK.showKeyboard('#search-input');

Parameter Description:

ParameterTypeDescription
selectorstringCSS selector for the target input box (optional, iOS only)

Synchronous method, no return value. In non-end environments, it is a no-op and throws no errors.

Platform Differences: Android uses an empty implementation (calling JS focus() on the input box within WebView automatically triggers the keyboard, so this method is unnecessary); iOS forwards the call to Native for handling.

⚠️ Internal API, do not call from business code. onJSBridgeReady is a ready notification automatically invoked by the SDK when the script loads, used to flush messages buffered by the Native side before the JSBridge becomes ready. Business code should not and does not need to call this method.