openMiniWidget(params: Object)

Requires:
BaseKit≥3.0.3@ray-js/ray≥0.8.0
Platforms:
iOSAndroid
import { openMiniWidget } from '@ray-js/ray';

// Promise usage
try {
  const res = await openMiniWidget({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Open the widget popup

Parameters

PropertyTypeRequiredDefaultDescriptionBaseKit Since
appIdstringYes-AppID of the widget to open-
pagePathstringNo-Relative URL of the widget page; if empty, opens the home page. The part after ? in path becomes the query-
deviceIdstringNo-Panel-type device ID-
groupIdstringNo-Panel-group type group ID-
stylestringNo"middle"Widget style, default: middle-
versionType"release" | "preview"No'release'Version type, default: release-
versionstringNo-Version-
position"bottom" | "top" | "center"No'bottom'Display position, default: bottom-
autoDismissbooleanNotrueWhether clicking outside closes the popupv3.0.4
autoCachebooleanNotrueWhether to prioritize showing the default cache. This property takes effect in Miniapp container 3.1.0v3.1.0
supportDarkbooleanNotrueWhether dark mode is supportedv3.1.3
complete() => voidNo-Completion callback (executed on both success and failure)-
success() => voidNo-Callback on successful API call-
fail(params: Object) => voidNo-Failure callback-
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

Type: MiniWidgetDialog
MiniWidgetDialog
PropertyTypeDescriptionBaseKit Since
dismissMiniWidgetfunctionClose the widget popup-
onWidgetDismissfunctionListen for the widget close eventv3.0.4
offWidgetDismissfunctionStop listening to the widget close eventv3.0.4

Valid Values

versionType
ValueDescriptionBaseKit Since
releaseProduction version-
previewPre-release version-
position
ValueDescriptionBaseKit Since
bottomDisplay at the bottom-
topDisplay at the top-
centerDisplay in the centerv3.4.0

Examples

import { home, openMiniWidget } from '@ray-js/ray'

// deviceId is an optional parameter for panel widgets; use the first device under the current account.
const { homeId } = await home.getCurrentHomeInfo();
const { devIds } = await home.getDeviceIdList({ ownerId: homeId, roomId: 80079606, devId: "vdevo178158139173829" });

const dialog = await openMiniWidget({
  appId: "ty8gpajcefnj0capj4",
  deviceId: devIds[0],
  pagePath: "/cards/alarm/index",
  position: "bottom",
  style: "1.3",
  versionType: "release",
  autoCache: false,
  autoDismiss: true,
  supportDark: true,
});

console.log(dialog);