Error while registering for push notification

hello to all,

this is my code for registering to Backendless push notification service:

private void registerDevice() {
txtLoading.setText(R.string.cServer);
Backendless.Messaging.registerDevice(“432293283701”, pushCity, new AsyncCallback() {
@Override
public void handleResponse(Void response) {
Log.e(“push”, “handleResponse: entering get device registration”);
try {
Backendless.Messaging.getDeviceRegistration(new AsyncCallback() {
@Override
public void handleResponse(DeviceRegistration response) {
MainActivity.deviceId = response.getDeviceId();
Log.e(“push”, "registerPush: " + response.getDeviceId());
txtLoading.setText(response.getDeviceId());
loadMain();
}

                    @Override
                    public void handleFault(BackendlessFault fault) {

                    }
                });


            } catch (Exception e) {
                Log.e("push", "registerPush: not working\n" + e.getLocalizedMessage());
            }
        }

        @Override
        public void handleFault(BackendlessFault fault) {

        }
    });
}

in the first time, it trying to register and going to endless loop
if I close my app and try again, all is working
why?

zeev

Hi, zeev.
I’ve checked your example and caught another strange behavior, but not endless loop.
I created an internal task to investigate the problem more deeply BKNDLSS-17522.

Hi Oleg, any News?
by endless loop, I mean it’s not going to handleResponse so the user is waiting forever.
but If I close the app and run it again, it’s working

Device registration is a complex task which consists of two registrations: on google server and on backendless server.
Method Backendless.Messaging.registerDevice() calls “handleResponse” of callback only when the google registration completed but not on backendless server.

If you want to catch and handle registration/send events related to our (backendless) server, you need to inherit class BackendlessPushService and override methods you want (onError, onMessage, onRegistered, onUnregistered).
public void onRegistered( Context context, String registrationId )
where registrationId – is a one string, where multiple registrations ids listed and separated by comma.

And do not forget to change the class name in AndroidManifest.xml.

        <service android:name=".receivers.YourPushService"
            android:permission="android.permission.BIND_JOB_SERVICE">
        </service>

Also for now we have a little inconsistency, and except ids the whole service data are passed as a string. It will be fixed soon.