subscribeReceivedThingModelMessage(params: Object)

Requires:
DeviceKit≥2.0.7@ray-js/ray≥0.6.23
Platforms:
iOSAndroid
import { device } from '@ray-js/ray';

const { subscribeReceivedThingModelMessage } = device;

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

Description

Subscribe to receive thing model messages. The onReceivedThingModelMessage event is delivered only after a successful subscription.

Parameters

PropertyTypeRequiredDescription
devIdstringYesDevice ID
complete() => voidNoCompletion callback (executed on both success and failure)
success() => voidNoCallback on successful API call
fail(params: Object) => voidNoFailure callback
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { device } from '@ray-js/ray'

device.subscribeReceivedThingModelMessage({
  devId: "xx",
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});