Interface DeviceInformationChange
- All Superinterfaces:
HttpOperation<DeviceInformationChange>
,Operation
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 Summary
Modifier and TypeMethodDescriptionDisables the push notifications on the server side (i.e.fcmRegistrationToken
(String fcmRegistrationToken) Specifies the new Firebase Cloud Messaging registration token.Specifies the new name of the device information.onError
(Consumer<DeviceInformationChangeError> errorConsumer) Specifies the object that will be invoked if the device information update failed.Specifies the object that will be invoked if the device information for the user was updated successfully.retryPolicy
(RetryPolicy retryPolicy) Specifies the retry policy to be used.Methods inherited from interface ch.nevis.mobile.sdk.api.operation.HttpOperation
requestHeaders
-
Method Details
-
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 methodfcmRegistrationToken(String)
.- Returns:
- a
DeviceInformationChange
-
name
Specifies the new name of the device information. This is typically a user-friendlyString
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
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 anDeviceInformationError
. This object will be invoked in the main/UI thread.Providing the object handling the error is required.
- Parameters:
errorConsumer
- the consumer of anDeviceInformationError
- Returns:
- a
DeviceInformationChange
-
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
-