Offline Device Alerts

Last Updated on : 2024-10-10 07:49:24download

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 ThingSuccessBOOL)success failure:(nullable ThingFailureError)failure;

Parameters

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

Example

Objective-C:

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

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

Swift:

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

Query status of offline alerts

API description

- (void)getOfflineReminderStatusWithSuccess:(nullable ThingSuccessBOOL)success failure:(nullable ThingFailureError)failure;

Parameters

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

Example

Objective-C:

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

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

Swift:

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

Set status of offline alerts

API description

- (void)setOfflineReminderStatus:(BOOL)status success:(nullable ThingSuccessBOOL)success failure:(nullable ThingFailureError)failure;

Parameters

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

Example

Objective-C:

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

    [self.device setOfflineReminderStatus:status success:^(BOOL result) {
        NSLog(@"Set offline reminder status: %d", result);
    } failure:^(NSError *error) {
        NSLog(@"Failed to set offline reminder status: %@", 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("Failed to set offline reminder status: \(e)")
        }
    })
}