Device Registration

Top  Previous  Next

In order to receive push notifications from Backendless, a device must be registered using the API documented below. Device registration may optionally include a list of messaging channels and/or an expiration date/time when the registration should be canceled.

 

Push notifications can be published using either API or Backendless Console. When a push notification is published, it goes through a messaging channel. Channels provide a way to establish a level of filtering - devices registered with a channel will receive notifications published to the channel. However, there are other way to narrow down push notification delivery. For example, a push notification may be sent to a specific device or a group of devices.

 

If no channels are specified in the device registration call, Backendless registers the device with the default channel. If the device registration call references a non-existing channel, Backendless creates the channel and registers the device with it. Registration expiration is a point in time (expressed as a timestamp) when the device registration must expire. Backendless removes the device registration at the specified time and the device no longer receives published push notifications.

 

In order to receive push notifications on a mobile device, application running on the device must register with Backendless using the API call below:

 

Method Signature

 

// register device with the "default" channel
public void registerDevice( String GCMSenderID )

// register device with the specified channel
public void registerDevice( String GCMSenderID, String channel )

// register device with the channels and assign expiration timestamp for the registration
public void registerDevice( String GCMSenderID, List<String> channels, Date expiration )

where:

gcmSenderID-  Google application project number. See the See the Google Project Number section in the Push Notification Setup section of the guide for information on how to obtain the GCM Sender ID
channel(s)- channel (or a collection of channels) to receive messages from. For the method without the argument, the "Default" channel is used.
expiration-  a timestamp when the device registration should expire.

Errors:

 

The following errors may occur during the message publishing 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

5004

Invalid expiration date. The expiration date must be after the current time.

8000

Property value exceeds the length limit. Error message should contain additional details about the violating property.

 

Example:

String applicationID = "";
String secretKey = "";
String version = "";
String gcmSenderID = "";
// this call must be somewhere in the app initialization section
Backendless.initApp( context, applicationId, secretKey, version);


Backendless.Messaging.registerDevice( gcmSenderID );

 


Please let us know how we can improve the documentation by leaving a comment. All technical questions should be posted to the Backendless Support forum. We do not respond to the technical questions on the documentation pages.: