English
English
简体中文
Contact Us
Register
Log In

IoT App SDK

Offline Device Alerts

Last Updated on : 2022-01-06 11:32:23

A device might get offline unexpectedly or do not respond over the network after the device is paired. In this case, you can enable offline alerts for the device. If the device goes offline, it will send a notification to a specified user. To enable this feature, you can subscribe to push notifications.

Check support for offline alerts

API description

- (void)getOfflineReminderSupportStatusWithSuccess:(nullable TYSuccessBOOL)success failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
success The success callback.
failure The failure callback.

Example

ObjC:

- (void)getCurrentOfflineReminderSupportStatus {
    // self.device = [TuyaSmartDevice deviceWithDeviceId:@"your_device_id"];

    [self.device getOfflineReminderSupportStatusWithSuccess:^(BOOL result) {
        NSLog(@"get current offline reminder support status: %d", result);
    } failure:^(NSError *error) {
        NSLog(@"get current Wifi Info failure: %@", error);
    }];
}

Swift:

func getCurrentOfflineReminderSupportStatus() {
    device?.getOfflineReminderSupportStatus(success: { status in
        print("get current offline reminder support status: \(status)")
    }, failure: { (error) in
        if let e = error {
          print("get current offline reminder support status failure: \(e)")
        }
    })
}

Query status of offline alerts

API description

- (void)getOfflineReminderStatusWithSuccess:(nullable TYSuccessBOOL)success failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
success The success callback.
failure The failure callback.

Example

ObjC:

- (void)getCurrentOfflineReminderStatus {
    // self.device = [TuyaSmartDevice deviceWithDeviceId:@"your_device_id"];

    [self.device getOfflineReminderStatusWithSuccess:^(BOOL result) {
        NSLog(@"get current offline reminder status: %d", result);
    } failure:^(NSError *error) {
        NSLog(@"get current Wifi Info failure: %@", error);
    }];
}

Swift:

func getCurrentOfflineReminderStatus() {
    device?.getOfflineReminderStatusWithSuccess(success: { status in
        print("get current offline reminder status: \(status)")
    }, failure: { (error) in
        if let e = error {
          print("get current offline reminder status failure: \(e)")
        }
    })
}

Set status of offline alerts

API description

- (void)setOfflineReminderStatus:(BOOL)status success:(nullable TYSuccessBOOL)success failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
status The status of offline alerts.
success The success callback.
failure The failure callback.

Example

ObjC:

- (void)setOfflineReminderStatus:(BOOL)status {
    // self.device = [TuyaSmartDevice deviceWithDeviceId:@"your_device_id"];

    [self.device setOfflineReminderStatus:status success:^(BOOL result) {
        NSLog(@"set Offline Reminder Status: %d", result);
    } failure:^(NSError *error) {
        NSLog(@"set Offline Reminder Status failure: %@", error);
    }];
}

Swift:

func setOfflineReminderStatus(status: Bool) {
    device?.getOfflineReminderStatusWithSuccess(success: { status in
        print("set offline reminder status: \(status)")
    }, failure: { (error) in
        if let e = error {
          print("set offline reminder status failure: \(e)")
        }
    })
}