You are using an async API and calls this methods in parallel.
There is no guaranty that device is already registered when you call gedDeviceRegistration.
You should make this call while handling the response of the registerDevice method call
The same error when I call in this way:
Backendless.Messaging.registerDevice(“senderid”, “default”, new AsyncCallback<Void>() { @Override
public void handleResponse(Void response) {
Backendless.Messaging.getDeviceRegistration(new AsyncCallback<DeviceRegistration>() { @Override
public void handleResponse(DeviceRegistration response) {
Log.d(TAG, "getDeviceRegistration handleResponse: " + response);
The reason of this behaviour is that the callback is called right after the device is registered in Google (for push notifications), but the registration in our internal database is still asynchronous.
You may try to overcome this by extending onRegistered() method from BackendlessPushService and retrieving the device registrations there. Or just don’t retrieve the registrations immediately is that’s possible.