Register Device
The registerDevice()
function is used to register User Device for Push Notifications.
Steps to Register User Device
- Create a RegisterDeviceRequest object using
RegisterDeviceRequest.builder()
class by passing all the required parameters. - Call
registerDevice()
function using the instance ofLMFeedClient
. - 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
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
token | String | FCM token generated for the user. | |
deviceId | String | Device ID of the user. |