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

## syncTimerTask

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

> [PLATFORM] iOS, Android

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

### Description

Synchronize timer tasks

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `deviceId` | `string` | No | - | `1.2.6` | deviceId Device ID; at least one of deviceId or groupId is required |
| `groupId` | `string` | No | - | `1.2.6` | groupId Group ID; at least one of deviceId or groupId is required |
| `category` | `string` | Yes | - | `1.2.6` | category Timer category |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `timers` | `TimerModel[]` | `3.3.0` | timers Timer list |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Referenced Types

##### `interface` TimerModel

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `timerId` | `string` | `3.3.0` | timerId Timer ID |
| `date` | `string` | `3.3.0` | date Date |
| `time` | `string` | `3.3.0` | time Time the timer runs |
| `status` | `boolean` | `3.3.0` | status Status |
| `loops` | `string` | `3.3.0` | loops 7-digit numeric string; "1000000" represents Sunday, "0100000" represents Monday |
| `dps` | `Record<string, Record<string, any>>` | `3.3.0` | dps DP point data, e.g.: {     "1": true,     "2": false } |
| `timezoneId` | `string` | `3.3.0` | timezoneId Time zone |
| `aliasName` | `string` | `3.3.0` | aliasName Alias |
| `isAppPush` | `boolean` | `3.3.0` | isAppPush Whether to send execution notifications |
| `id` | `string` | `3.3.0` | id Task ID |


### Examples

#### Basic usage

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

const { syncTimerTask } = device;

syncTimerTask({
  category: 'example',
  success: (result) => {
    console.log('syncTimerTask success', result);
  },
  fail: (error) => {
    console.log('syncTimerTask fail', error.errorMsg);
  },
});
```
