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<Void>() {
@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();
}
});
}
}
});