How Can I Migrate Between Beams Instances?

If there is a requirement to migrate from one Beams instance to another within your app then you should call the stop method in your client before registering to the new instance. This will remove all state related to the old instance and allow a successful registration to the new instance.

Failure to call stop before registering to new instance will cause the following error to be thrown: "This device has already been registered to a Pusher Push Notifications application with instance ID <OLD_INSTANCE_ID>"

To overcome this error you will need to manually remove all state from the device. To do this you can use the below code snippets:


   let userDefaults = UserDefaults(suiteName: "PushNotifications")
        let persistedInstanceId = userDefaults?.value(forKey: "com.pusher.sdk.instanceId") as! String        if (persistedInstanceId == "OLD_INSTANCE_ID") {
            UserDefaults(suiteName: "PushNotifications").map { userDefaults in
            self.pushNotifications.start(instanceId: "NEW-INSTANCE-ID")
        } else {
            self.pushNotifications.start(instanceId: "NEW-INSTANCE-ID")


DeviceStateStore deviceStateStore = new DeviceStateStore(applicationContext);
if (deviceStateStore.getInstanceId().equals("OLD_INSTANCE_ID")) {
    Log.e("TESTING", "clearing state");

You can then register and start the notifications client with the new instance ID as normal.

Still have questions? Please reach out to our Support team by visiting this page.

Last updated