Skip to main content

Register Device for Notifications

To receive push notifications, you need to register a device using the registerDevice() function.

Steps to Register a Device

  1. Build a RegisterDeviceRequest object using the RegisterDeviceRequestBuilder class.

  2. Call the registerDevice() function using the instance of the LMFeedClient class.

  3. Use the response as per your requirement.

     // Provide device details for registration
    String token = "device_token_here";
    String deviceId = "device_id_here";
    int memberId = 123; // replace with actual member ID

    // Build the request object
    RegisterDeviceRequest request = (RegisterDeviceRequestBuilder()
    ..token(token)
    ..deviceId(deviceId)
    ..memberId(memberId))
    .build();

    // Get the response from calling the function
    final RegisterDeviceResponse response = await lmFeedClient.registerDevice(request);

    // Process the response, as per requirement
    if(response.success){
    // your function to handle successful device registration
    handleDeviceRegistration(response);
    }else{
    // your function to handle error message
    handleRegistrationError(response.errorMessage);
    }
tip

Registering a device allows it to receive push notifications from the LikeMinds Feed.

Models

RegisterDeviceRequest

List of parameters for the RegisterDeviceRequest class

VariableTypeDescriptionOptional
tokenStringDevice token for notifications
deviceIdStringUnique ID of the registered device
memberIdintMember ID associated with the device

RegisterDeviceResponse

List of parameters for the RegisterDeviceResponse class

VariableTypeDescriptionOptional
errorMessageStringError message in case of failure
successboolAPI success status