设置消息推送

更新时间:2023-11-08 09:17:53下载pdf

查询 App 消息推送的开启状态

消息推送开关为总开关,关闭状态下无法接收到设备告警、家庭消息、通知消息等任何消息。

接口说明

void getPushStatus(IThingResultCallback<PushStatusBean> callback);

参数说明

参数 说明
callback 回调,包括查询总开关状态成功和失败

示例代码

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

开启或者关闭 App 消息推送

消息推送开关为总开关,关闭状态下无法接收到 设备告警、家庭消息、通知消息等任何消息。

接口说明

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

参数说明

参数 说明
isOpen 是否开启
callback 回调,包括设置成功和失败

示例代码

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

根据消息类型查询消息的开关状态

接口说明

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

参数说明

参数 说明
type 消息类型:
  • 0:告警消息
  • 1:家庭消息
  • 2:通知消息
  • 4:营销消息
callback 回调,包括查询成功和失败

示例代码

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

根据消息类型设置消息的开关状态

接口说明

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

参数说明

参数 说明
type 消息类型:
  • 0:告警消息
  • 1:家庭消息
  • 2:通知消息
  • 4:营销消息
isOpen 是否开启
callback 回调,包括设置成功和失败

示例代码

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

查询已经设置的免打扰时间段

接口说明

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

参数说明

参数 说明
listener 回调,包括设置成功和失败

示例代码

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

查询家庭下设备的免打扰设置

接口说明

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

参数说明

参数 说明
listener 回调,包括设置成功和失败

示例代码

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

查询设备消息免打扰开关状态

接口说明

void getDeviceDNDSetting(IThingDataCallback<Boolean> listener);

参数说明

参数 说明
listener 回调,返回成功包含开关状态
  • open:true
  • close:false

示例代码

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

开启或者关闭设备消息免打扰开关

接口说明

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

参数说明

参数 说明
open 开启或关闭
listener 回调,包括设置成功和失败

示例代码

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

添加消息免打扰时段

接口说明

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

参数说明

参数 说明
startTime 开始时间
endTime 结束时间
devIds allDevIdstrue 时为所有设备,当为 false 时,取 devIds 里的设备 ID。示例:{allDevIds:false,devIds:[“deviceId”]}
loops 每周重复次数
listener 回调,包括设置成功和失败

示例代码

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

移除消息免打扰时间

接口说明

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

参数说明

参数 说明
id 免打扰时段的 ID
listener 回调,包括设置成功和失败

示例代码

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

修改消息免打扰时间

接口说明

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

参数说明

参数 说明
nodisturbAlarmId 免打扰时段的 ID
mStartTime 开始时间
mEndTime 结束时间
loops 每周重复次数
listener 回调,包括设置成功和失败

示例代码

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) {}
});