---
name: "onReceivedThingModelMessage"
mode: "kit"
versionRequirements:
  - { name: "DeviceKit", version: "2.0.7" }
  - { name: "@ray-js/ray", version: "0.6.23" }
platform:
  - "iOS"
  - "Android"
async: true
---

## onReceivedThingModelMessage

> [VERSION] DeviceKit >= 2.0.7 | @ray-js/ray >= 0.6.23

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Receive thing model message event. You will only receive this event after subscribing with subscribeReceivedThingModelMessage.

### Parameters

`(listener: Function)`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `listener` | `(params: OnReceivedThingModelMessageBody) => void` | Yes | - |  |

### Referenced Types

##### `interface` OnReceivedThingModelMessageBody

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `type` | `number` | `2.0.7` | Type 0: Property, 1: Action, 2: Event |
| `payload` | `Record<string, any>` | `2.0.7` | Thing model message body in key-value form; field meanings vary by type (property/action/event) |


### Examples

#### Basic usage

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

const { onReceivedThingModelMessage } = device;

onReceivedThingModelMessage((res) => {
  console.log('onReceivedThingModelMessage', res);
});
```
