Update PushID
This workflow consists of sending the new PushID to the server if this information has changed compared to the previously registered value. If this is not done, then the application will not be able to receive Push Notifications from the server as the values on the server side and on the device side will not be synchronized. The PushID value might change after an event such as a device OS update.
The mobile application updates the PushID as follows:
-
Create an instance of the Device (DeviceFactory.newInstance).
-
Retrieve an instance of the Container (Device.findContainer).
-
Update the DEVICE_INFO_PUSHID property (Container.updateDeviceInfo).
// We assume that you have already provisioned a container.
// we assume session key is not password protected (password null)
try {
myContainer.updateDeviceInfo( SDKConstants.DEVICE_INFO_PUSHID, newPushId.toCharArray(),null,arrayOfNulls(0))
println("Push id successfully updated")
myContainer.updateDeviceInfo( SDKConstants.DEVICE_INFO_NAME, newDeviceName.toCharArray(), null, arrayOfNulls(0))
println("Device name successfully updated")
}
catch (ex: Exception) {
when(ex) {
is RemoteException, is AuthenticationException, is UnsupportedDeviceException, is InternalException, is LostCredentialsException, is FingerprintAuthenticationRequiredException, is ServerOperationFailedException, is InvalidParameterException -> {
ex.printStackTrace()
}
else -> throw ex
}
}
// We assume that you have already provisioned a container.
// we assume session key is not password protected (password null)
try {
myContainer.updateDeviceInfo( SDKConstants.DEVICE_INFO_PUSHID, newPushId.toCharArray(), null, new Parameter[0]);
Log.d(LOG_TAG,"Push id successfully updated");
myContainer.updateDeviceInfo( SDKConstants.DEVICE_INFO_NAME, newDeviceName.toCharArray(), null, new Parameter[0]);
Log.d(LOG_TAG,"Device name successfully updated");
} catch (RemoteException | AuthenticationException | UnsupportedDeviceException | InternalException | LostCredentialsException | FingerprintAuthenticationRequiredException | ServerOperationFailedException | InvalidParameterException e) {
e.printStackTrace();
}