Skip to content

Cancel Device Registration

To cancel the registration of a device with Backendless, an application can use the API described below:

// Remove device registration for the current device
- (void)unregisterDeviceWithResponseHandler:^(BOOL)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;

// Remove device registration for a device with deviceId
- (void)unregisterDeviceWithDeviceId:(NSString * _Nonnull)deviceId responseHandler:^(BOOL)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
// Remove device registration for the current device
func unregisterDevice(responseHandler: ((Bool) -> Void)!, errorHandler: ((Fault) -> Void)!)

// Remove device registration for a device with deviceId
func unregisterDevice(deviceId: String, responseHandler: ((Bool) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument
Description
deviceId
device identifier

Return value:

A boolean value indicating whether registration cancellation has succeeded. True - successful cancellation, false otherwise.

Errors

The following errors may occur during the device registration cancellation API callThe following errors may occur during the device registration API call. See the Error Handling section for details on how to retrieve the error code when the server returns an error:

Error Code
Description
5001
Unable to cancel device registration - unknown device ID.

Example

[Backendless.shared.messaging unregisterDeviceWithDeviceId:@"XXXXX" responseHandler:^(BOOL isUnregistered) {
    NSLog(@"Device registration canceled %i", isUnregistered);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Backendless.shared.messaging.unregisterDevice(deviceId: "XXXXX", responseHandler: { isUnregistered in
    print("Device registration canceled: \(isUnregistered)")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})