Update PushID

View this page for | |

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:

  1. Create an instance of the Device (DeviceFactory.newInstance).

  2. Retrieve an instance of the Container (Device.findContainer).

  3. Update the DEVICE_INFO_PUSHID property (Container.updateDeviceInfo).

Note: To disable push notifications for the device, the PushID value should be left blank (empty string).
Copy
// 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
        }
    }
Copy
// 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();
     }