Skip to content

Retrieve Device Registration

Backendless server returns information about device registration with the API documented below. The input parameter of the API is deviceId - the value returned by the device registration API.

- (void)getDeviceRegistrationsWithResponseHandler:^(NSArray<DeviceRegistration *> * _Nonnull)responsehandler errorHandler:^(Fault * _Nonnull)errorHandler;
- (void)getDeviceRegistrationsWithDeviceId:(NSString * _Nonnull)deviceId responseHandler:^(NSArray<DeviceRegistration *> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func getDeviceRegistrations(responseHandler: (([DeviceRegistration]) -> Void)!, errorHandler: ((Fault) -> Void)!)
func getDeviceRegistrations(deviceId: String, responseHandler: (([DeviceRegistration]) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

deviceId        - Device Identifier;


Return value:

An array with one object containing device registration details - An instance of the DeviceRegistration class. Provides access to the following properties:

Argument                Description
deviceToken A token assigned by the push notification service provider (Google Cloud Messaging, Apple Push Notification Service, Microsoft Push Notification Service).
deviceId A unique identification of the device registered to receive push notifications.
os Operating system identifier
osVersion Version of the operating system
channels An array of Backendless messaging channels device is registered with.
expiration A timestamp indicating when the device registration should expire.

Use the following API to retrieve device's deviceId:

DeviceRegistration *deviceRegistration = [Backendless.shared.messaging currentDevice];
NSString *deviceId = deviceRegistration.deviceId;
let deviceRegistration = Backendless.shared.messaging.currentDevice()
let deviceId = deviceRegistration.deviceId

Errors:

The following errors may occur during the device registration 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
5000
Unable to retrieve device registration - unknown device ID.

Example

[Backendless.shared.messaging getDeviceRegistrationsWithDeviceId:@"XXXXX" responseHandler:^(NSArray *deviceRegistrations) {
    for (DeviceRegistration *deviceRegistration in deviceRegistrations) {
        NSLog(@"%@", deviceRegistration);
    }
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Backendless.shared.messaging.getDeviceRegistrations(deviceId: "XXXXX", responseHandler: { deviceRegistrations in
    for deviceRegistration in deviceRegistrations {
        print(deviceRegistration)
    }
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

Codeless Reference

push_get_device_registration_1

Returns a list with one object containing device registration details. The object contains the following properties:

where:

Argument                Description
deviceToken A token assigned by the push notification service provider (Google Cloud Messaging, Apple Push Notification Service, Microsoft Push Notification Service).
deviceId A unique identification of the device registered to receive push notifications.
os Operating system identifier
osVersion Version of the operating system
channels An array of Backendless messaging channels device is registered with.
expiration A timestamp indicating when the device registration should expire.

The example below retrieves the device registration details:

push_get_device_registration_2