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. Recuperate the Apple Push Notification service (APNs) device token identifier and encode as a base64 string.

  2. Create an instance of the HIDDevice (HIDDeviceFactory.newInstance).

  3. Retrieve an instance of the HIDContainer (HIDDevice.findContainer).

  4. Update the DEVICE_INFO_PUSHID property (HIDContainer.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.
    do {
        // we assume session key is not password protected (password nil)
        // encode APNs device token as base64
        let deviceTokenB64 = deviceToken.base64EncodedString()

        try myContainer.updateInfo(HID_DEVICE_INFO_PUSHID, withValue: deviceTokenB64, withPassword: nil, withParams: nil)
        NSLog("Push id successfully updated")
        
        try myContainer.updateInfo(HID_DEVICE_INFO_NAME, withValue: myName, withPassword: nil, withParams: nil)
        NSLog("Device name successfully updated")
    }
    catch let error as NSError{
        NSLog("update device info failed: %@"", error.localizedDescription)
    }
Copy
// We assume that you have already provisioned a container.
    // encode APNs device token as base64
    NSString * deviceTokenB64 = [deviceToken base64EncodedStringWithOptions :0]
                                
    // we assume session key is not password protected (password nil)
    [myContainer updateDeviceInfo:HID_DEVICE_INFO_PUSHID withValue:deviceTokenB64 withPassword:nil withParams:nil error:&error];
    if(!error){
        NSLog("Push id successfully updated");
    }
    
    [myContainer updateDeviceInfo:HID_DEVICE_INFO_NAME withValue:myName withPassword:nil withParams:nil error:&error];
    if(!error) {
        NSLog("Device name successfully updated")
    }