Cancel Device Registration¶
To cancel the registration of a device with Backendless, an application can use the API described below:
Method¶
// unregisters device from the specified Backendless messaging channels.
// If channels is not specified, device is unregistered from all channels.
Future<int> Backendless.messaging.unregisterDevice([List<String> channels]);
Return value¶
The int
value that identifies the number of channels which the device is still registered with in Backendless. This information is helpful to determine if the device should also be unregistered from FCM. When the number of remaining registrations in Backendless is zero, in some cases it might be needed to unregister from FCM as well.
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¶
String applicationId = "YOUR-APP-ID";
String androidApiKey = "ANDROID-KEY";
String iosApiKey = "IOS-KEY";
// this call must be somewhere early on in the application initialization
Backendless.initApp(applicationId, androidApiKey, iosApiKey);
Backendless.messaging.unregisterDevice().then((response) {
print("Device unregistered");
});
Codeless Reference¶
Returns the integer value identifying the number of channels which the device is still registered with in Backendless. This information is helpful to determine if the device should also be unregistered from FCM. When the number of remaining registrations in Backendless is zero, in some cases it might be needed to unregister from FCM as well.
The example below cancels the registration of a device with Backendless: