Skip to main content

Register Device

The registerDevice() function is used to register User Device for Push Notifications.

Steps to Register User Device

  1. Create a RegisterDeviceRequest object using RegisterDeviceRequest.builder() class by passing all the required parameters.
  2. Call registerDevice() function using the instance of LMFeedClient.
  3. Process the response (LMResponse<Nothing>) as per your requirement.
CoroutineScope(Dispatchers.IO).launch {
// object of RegisterDeviceRequest
val registerDeviceRequest = RegisterDeviceRequest.Builder()
.token("ENTER FCM TOKEN") // FCM token
.deviceId("ENTER DEVICE ID") // unique id of the device
.build()
// get response (LMResponse<RegisterDeviceResponse>)
val response = LMFeedClient.getInstance().registerDevice(registerDeviceRequest)
if (response.success) {
// your function to process the response data
processRegisterDeviceResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}

Models

RegisterDeviceRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
tokenStringFCM token generated for the user.
deviceIdStringDevice ID of the user.