Set Push Messages

Last Updated on : 2024-07-18 09:53:36download

Check push messages on/off status

When the main switch of the push message service is disabled, the app will not receive any alerts, home messages, or notices from the device.

API description

void getPushStatus(IThingResultCallback<PushStatusBean> callback);

Parameters

Parameter Description
callback The success or failure callback.

Example

 ThingHomeSdk.getPushInstance().getPushStatus(new IThingResultCallback<PushStatusBean>() {
       @Override
       public void onSuccess(PushStatusBean result) {}
       @Override
       public void onError(String errorCode, String errorMessage) {}
 });

Enable or disable push messages

When the main switch of the push message service is disabled, the app will not receive any alerts, home messages, or notices from the device.

API description

void setPushStatus(boolean isOpen, IThingDataCallback<Boolean> callback);

Parameters

Parameter Description
isOpen Specifies whether to enable this feature.
callback The success or failure callback.

Example

ThingHomeSdk.getPushInstance().setPushStatus(open, new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Check push messages on/off status by message type

API description

void getPushStatusByType(PushType type, IThingDataCallback<Boolean> callback);

Parameters

Parameter Description
type The message type:
  • 0: Alert
  • 1: Home message
  • 2: Notice message
  • 4: Marketing message
callback The success or failure callback.

Example

ThingHomeSdk.getPushInstance().getPushStatusByType(type, new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Set push messages by message type

API description

void setPushStatusByType(PushType type, isOpen, IThingDataCallback<Boolean> callback);

Parameters

Parameter Description
type The message type:
  • 0: Alert
  • 1: Home message
  • 2: Notice message
  • 4: Marketing message
isOpen Specifies whether to enable this feature.
callback The success or failure callback.

Example

ThingHomeSdk.getPushInstance().setPushStatusByType(pushType, checked, new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Check recurring do-not-disturb (DND) periods

API description

void getDNDList(IThingDataCallback<ArrayList<DeviceAlarmNotDisturbVO>> listener);

Parameters

Parameter Description
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().getDNDList(new IThingDataCallback<DeviceAlarmNotDisturbVO>() {
      @Override
      public void onSuccess(DeviceAlarmNotDisturbVO result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Check one-time DND periods

API description

void getOnceDNDList(IThingDataCallback<ArrayList<DeviceAlarmNotDisturbVO>> listener);

Parameters

Parameter Description
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().getOnceDNDList(new IThingDataCallback<DeviceAlarmNotDisturbVO>() {
      @Override
      public void onSuccess(DeviceAlarmNotDisturbVO result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

The loop for a one-time DND period is "0000000", while for a recurring DND period, it is different.

Query DND settings for devices

API description

void getDNDDeviceList(IThingDataCallback<ArrayList<NodisturbDevicesBean>> listener);

Parameters

Parameter Description
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().getDNDDeviceList(new IThingDataCallback<NodisturbDevicesBean>() {
      @Override
      public void onSuccess(NodisturbDevicesBean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Query DND on/off for push messages

API description

void getDeviceDNDSetting(IThingDataCallback<Boolean> listener);

Parameters

Parameter Description
listener The callback. The on/off status is returned on success callback.
  • true: On
  • false: Off

Example

ThingHomeSdk.getMessageInstance().getDeviceDNDSetting(new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Enable or disable DND for push messages

API description

void setDeviceDNDSetting(boolean open, IThingDataCallback<Boolean> listener);

Parameters

Parameter Description
open Enable or disable.
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().setDeviceDNDSetting(open, new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Add a recurring DND period

API description

void addDNDWithStartTime(String startTime, String endTime, String devIds, String loops, IThingDataCallback<Long> listener);

Parameters

Parameter Description
startTime The start time, in the format HH:mm, for example, 07:59.
endTime The end time, in the format HH:mm, for example, 08:59.
devIds When allDevIds is true, all devices apply. When it is false, only the specified devIds applies. Example: {allDevIds:false,devIds:["deviceId"]}
loops The weekly recurrence frequency, in the format "xxxxxxx". For example, "1000000" indicates the DND period repeats every Sunday.
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().addDNDWithStartTime(startTime, endTime, devIds, loops, new IThingDataCallback<Long>() {
      @Override
      public void onSuccess(Long result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Add a one-time DND period

API description

void addOnceDNDWithStartTime(String startTime, String endTime, String devIds, IThingDataCallback<Long> listener);

Parameters

Parameter Description
startTime The start time, in the format YYYY-MM-DD HH:mm, for example 2024-06-20 20:00.
endTime The end time, in the format YYYY-MM-DD HH:mm, for example 2024-06-20 21:00.
devIds When allDevIds is true, all devices apply. When it is false, only the specified devIds applies. Example: {allDevIds:false,devIds:["deviceId"]}
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().addOnceDNDWithStartTime(startTime, endTime, devIds, new IThingDataCallback<Long>() {
      @Override
      public void onSuccess(Long result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Remove a DND period

API description

void removeDNDWithTimerId(long id, IThingDataCallback<Boolean> listener);

Parameters

Parameter Description
id The ID of the DND period.
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().removeDNDWithTimerId(id, new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Modify a recurring DND period

API description

void modifyDNDWithTimerId(long nodisturbAlarmId, String mStartTime, String mEndTime, String devIds, String loops, IThingDataCallback<Boolean> listener);

Parameters

Parameter Description
nodisturbAlarmId The ID of the DND period.
mStartTime The start time, in the format HH:mm, for example, 07:59.
mEndTime The end time, in the format HH:mm, for example, 07:59.
loops The weekly recurrence frequency, in the format "xxxxxxx". For example, "1000000" indicates the DND period repeats every Sunday.
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().modifyDNDWithTimerId(nodisturbAlarmId, mStartTime, mEndTime, devIds, loops, new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});

Modify a one-time DND period

API description

void modifyOnceDNDWithTimerId(long nodisturbAlarmId, String mStartTime, String mEndTime, String devIds, IThingDataCallback<Boolean> listener);

Parameters

Parameter Description
nodisturbAlarmId The ID of the DND period.
mStartTime The start time, in the format YYYY-MM-DD HH:mm, for example 2024-06-20 20:00.
mEndTime The end time, in the format YYYY-MM-DD HH:mm, for example 2024-06-20 21:00.
listener The success or failure callback.

Example

ThingHomeSdk.getMessageInstance().modifyOnceDNDWithTimerId(nodisturbAlarmId, mStartTime, mEndTime, devIds, new IThingDataCallback<Boolean>() {
      @Override
      public void onSuccess(Boolean result) {}
      @Override
      public void onError(String errorCode, String errorMessage) {}
});