Device Offline Notification

Last Updated on : 2024-05-12 05:07:45download

Overview

The device offline notification enables you to:

  • Check support for offline notifications
  • Get offline notification status
  • Update offline notification status

Implementation

Initialization

Get the management class for device offline notifications.

val manager = DeviceBusinessDataManager.getInstance().getDeviceOfflineReminderManager()

Step 1: Check support for offline notifications

Check if the device supports offline notifications by device ID.

manager.getOfflineReminderSupportStatus(deviceId,
    object : ResultListener<IsSupportOffLineBean?> {
        override fun onFailure(
            response: BusinessResponse?,
            isSupoort: IsSupportOffLineBean?,
            apiName: String?
        ) {

        }

        override fun onSuccess(
            response: BusinessResponse?,
            offLineBean: IsSupportOffLineBean?,
            apiName: String?
        ) {

        }
    })

Step 2: Get offline notification status

If the device supports offline notifications, request the current offline notification status by device ID.

manager.getOfflineReminderStatus(deviceId,
    object : ResultListener<ArrayList<OffLineStatusBean?>?> {
        override fun onFailure(
            response: BusinessResponse?,
            p1: ArrayList<OffLineStatusBean?>?,
            apiName: String?
        ) {

        }

        override fun onSuccess(
            response: BusinessResponse?,
            statusBeans: ArrayList<OffLineStatusBean?>?,
            apiName: String?
        ) {

        }
    })

Step 3: Update offline notification status

With the status obtained in the previous step, update the offline notification status with the device ID and offline notification toggle.

manager.updateOfflineReminderStatus(deviceId, isOpen, object : ResultListener<Boolean> {
    override fun onFailure(response: BusinessResponse?, isOpen: Boolean?, apiName: String?) {

    }

    override fun onSuccess(response: BusinessResponse?, isOpen: Boolean?, apiName: String?) {
        Toast.makeText(
            this@DeviceOfflineRemindSettingActivity,
            resources.getString(R.string.update_success),
            Toast.LENGTH_SHORT
        ).show()
    }
})

Demo

This topic describes the service implementation in the sequence of read and create operations. In real-world projects, you can implement them as needed. For more information, see the Offline Notification Module in the BizBundle SDK Demo.