Interface DeviceInformationChange

All Superinterfaces:
HttpOperation<DeviceInformationChange>, Operation

public interface DeviceInformationChange extends HttpOperation<DeviceInformationChange>
The object that updates a device information. The device information update can be used to modify the name of the device and its Firebase registration token.

Examples:

  private void updateDeviceInformation(Operations operations, String newName, String newFcmRegToken) {
      operations.deviceInformationChange()
          .name(newName)
          .fcmRegistrationToken(newFcmRegToken)
          .onError(error -> {
              // handle error
          })
          .onSuccess(() -> {
              // handle success
          })
          .execute();
  }

  private void updateDeviceInformationFcmRegistrationToken(Operations operations, String newFcmRegToken) {
      operations.deviceInformationChange()
          .fcmRegistrationToken(newFcmRegToken)
          .onError(error -> {
              // handle error
          })
          .onSuccess(() -> {
              // handle success
          })
          .execute();
  }
 
If neither name(String) or fcmRegistrationToken(String) are provided, the provided onSuccess Runnable object will be called when Operation.execute() is invoked.
  • Method Details

    • fcmRegistrationToken

      DeviceInformationChange fcmRegistrationToken(String fcmRegistrationToken)
      Specifies the new Firebase Cloud Messaging registration token.

      Do not invoke this method if the Firebase Cloud Messaging registration token does not need to be updated.

      Parameters:
      fcmRegistrationToken - the new Firebase Cloud Messaging registration token
      Returns:
      a DeviceInformationChange
    • disablePushNotifications

      DeviceInformationChange disablePushNotifications()
      Disables the push notifications on the server side (i.e. the server will not send authentication push notifications).

      To re-enable the sending of push notifications, execute a DeviceInformationChange and provide the Firebase Cloud Messaging registration token through the method fcmRegistrationToken(String).

      Returns:
      a DeviceInformationChange
    • name

      Specifies the new name of the device information. This is typically a user-friendly String describing the mobile device where the application is running. For example:
           Work Samsung Galaxy S10
       

      Do not invoke this method if the name does not need to be updated.

      Parameters:
      name - the new device information name
      Returns:
      a DeviceInformationChange
    • retryPolicy

      DeviceInformationChange retryPolicy(RetryPolicy retryPolicy)
      Specifies the retry policy to be used. For some errors (such as networking errors) retrying is meaningful, this parameter specifies the retry policy to be followed if one of these errors occurs.

      If no retry policy is provided RetryPolicy.NoRetry will be used.

      The retry strategy can be useful when updating the Firebase Cloud Messaging token. But since it is not known when the token will be updated, synchronization is necessary and should be done by the caller. The following code guarantees that the last change on the FCM token is executed only after the ongoing one finishes:

       private DeviceInformationChange awaitingChange = null;
       private DeviceInformationChange runningChange = null;
      
       public void modifyFcmRegistrationToken(Operations operations, String newFcmRegistrationToken) {
           DeviceInformationChange change = operations.deviceInformationChange()
               .fcmRegistrationToken(newFcmRegistrationToken)
               .onError(deviceInformationChangeError --> onModifyFinished())
               .onSuccess(() -> onModifyFinished());
           synchronized (this) {
               if (runningChange == null) {
                   change.execute();
                   runningChange = change;
               } else {
                   awaitingChange = change;
               }
           }
       }
      
       private synchronized void onModifyFinished() {
           if (awaitingChange != null) {
               awaitingChange.execute();
               runningChange = awaitingChange;
                     awaitingChange = null;
           } else {
               runningChange = null;
           }
       }
       
      Parameters:
      retryPolicy - the retry policy
      Returns:
      a DeviceInformationChange
    • onError

      Specifies the object that will be invoked if the device information update failed. The specified object will receive an DeviceInformationError. This object will be invoked in the main/UI thread.

      Providing the object handling the error is required.

      Parameters:
      errorConsumer - the consumer of an DeviceInformationError
      Returns:
      a DeviceInformationChange
    • onSuccess

      DeviceInformationChange onSuccess(Runnable onSuccess)
      Specifies the object that will be invoked if the device information for the user was updated successfully. This object will be invoked in the main/UI thread.

      Providing the object handling the success is required.

      Parameters:
      onSuccess - the object invoked on successful update.
      Returns:
      a DeviceInformationChange