How to get device ID at the time of registration for push notification

Hello,

I need device ID to send push notifications for dedicated devices, for this i need device at the time of registration.

Here is the code, i have been trying.

For very first time, code hits to Backendless.Messaging.registerDevice Method. In response ill get just void.

How can i get the Device ID as soon as it gets registered to Backendless server?.

Backendless.initApp(mAppContext, YOUR_APP_ID, YOUR_SECRET_KEY, appVersion);
Backendless.Messaging.getDeviceRegistration(new AsyncCallback<DeviceRegistration>() {
@Override
public void handleResponse(DeviceRegistration deviceRegistration) {

    Toast.makeText(mAppContext, "Device already Registered, Remove this line Later", Toast.LENGTH_LONG).show();
}

@Override
public void handleFault(BackendlessFault backendlessFault) {

    if(backendlessFault.getCode().equals(Constants.BACK_ENDLESS_ERR_REGISTRATION))
    {

        Backendless.Messaging.registerDevice(GCM_ID, CHANNEL_NAME, new AsyncCallback&lt;Void&gt;() {
            @Override
            public void handleResponse(Void aVoid) {

                Toast.makeText(mAppContext, "Device Registration success, remove this line later", Toast.LENGTH_LONG).show();

                SharedPreferences.Editor settings = context.getSharedPreferences("DeviceRegID", Context.MODE_PRIVATE).edit();


                settings.commit();
            }

            @Override
            public void handleFault(BackendlessFault backendlessFault) {

                Toast.makeText(mAppContext, backendlessFault.getMessage(), Toast.LENGTH_LONG).show();
            }
        });
    }
}

});

Hello!

There is no way to get deviceID on registration.
You should use method “Backendless.Messaging.getRegistrations” as described here: https://backendless.com/documentation/messaging/android/messaging_retrieve_device_registration.htm
best regards,
Alex