Host methods
callHostMethod(methodName, params)
Section titled “callHostMethod(methodName, params)”Call custom methods of the host app to implement business extensions.
const result = await SuperSDK.callHostMethod('getUserInfo', { id: '123' });console.log(result);Parameter Description:
| Parameter | Type | Description |
|---|---|---|
| methodName | string | Method Name |
| params | object | Parameter 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
HostMethodServiceinterface to register custom methods.
reportEvent(eventName, params)
Section titled “reportEvent(eventName, params)”Report events to the SDK’s built-in analytics (implemented via SReporter).
await SuperSDK.reportEvent('page_view', { page: 'home', duration: 1200 });Parameter Description:
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event Name |
| params | object | Event Parameters (Optional) |
openBrowser(url, title)
Section titled “openBrowser(url, title)”Open browser page (SDK built-in implementation; Android uses the system browser, iOS uses SFSafariViewController).
SuperSDK.openBrowser('https://example.com', 'Example page');Parameter Description:
| Parameter | Type | Description |
|---|---|---|
| url | string | URL to open |
| title | string | Page Title |
showToast(message)
Section titled “showToast(message)”Display Toast notification (SDK built-in implementation; Android uses system Toast, iOS uses custom overlay).
SuperSDK.showToast('Success');Parameter Description:
| Parameter | Type | Description |
|---|---|---|
| message | string | Message Content |
reportEvent,showToast, andopenBrowserare all built-in SDK implementations and do not require additional handling by the host app.
addEventCommonParam(key, value)
Section titled “addEventCommonParam(key, value)”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:
| Parameter | Type | Description |
|---|---|---|
| key | string | Common Parameter Keys |
| value | string | Common 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.
submitFeedback(params)
Section titled “submitFeedback(params)”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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| scene | string | ✓ | Feedback scenario, ≤64 characters |
| subScene | string | Sub-scenario, ≤64 characters | |
| title | string | ✓ | Title, ≤200 characters |
| content | string | ✓ | Feedback content, ≤5000 characters |
| userId | string | Business user ID, ≤128 characters; if not provided, the console user_id is empty. | |
| extra | object | Additional information, JSON object, serialized size ≤4KB |
Return value: Promise<{ feedbackId: number }> — Server-side feedback record ID.
Error:
| Scenario | In-app (JSB) | web |
|---|---|---|
| Invalid parameter (length/type) | reject Error('INVALID_PARAMS'), with err.detail containing the reason | SuperSDKError INVALID_ARGUMENT |
| Not initialized | - | NOT_INITIALIZED |
| Server-side business rejection | Field 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/Timeout | reject 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.
setStatusBarDarkMode(isDark)
Section titled “setStatusBarDarkMode(isDark)”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:
| Parameter | Type | Description |
|---|---|---|
| isDark | boolean | true=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.
showKeyboard(selector)
Section titled “showKeyboard(selector)”Invoke the soft keyboard.
SuperSDK.showKeyboard('#search-input');Parameter Description:
| Parameter | Type | Description |
|---|---|---|
| selector | string | CSS 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.
onJSBridgeReady (internal interface)
Section titled “onJSBridgeReady (internal interface)”⚠️ Internal API, do not call from business code.
onJSBridgeReadyis 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.