Push notifications device registration

Hi
I am trying to setup push notifications within a nativescript application. I have successfully configured and setup the FCM and obtain a registration token which we use within the register device call but we get errors

Backendless Version (3.x / 5.x, Online / Managed / Pro )

Online

Client SDK (REST / Android / Objective-C / Swift / JS )

JS

Application ID

E27B10A2-C4B9-A5A6-FF6A-AB65CBE35A00

Expected Behavior

  1. Register device for push notifications

Actual Behavior

  1. Backendless.Messaging.registerDevice throws “Device is not defined. Please, run the Backendless.setupDevice”

  2. However if I try to call Backendless.setupDevice with following device properties

{
“uuid”: “753bc5dd3b5228c3”,
“platform”: “Android”,
“version”: “7.0”
}

We get

"The sync methods of the Backendless API are deprecated and will be removed in the nearest future.
Please, use async methods instead.
error {
“message”: “unknown error occurred”,
“statusCode”: null
}
"

Thank You
Constantin

Hi Constantin,

are you sure you get this error when you call Backendless.setupDevice?
Because it does not have a wrapper that would warn about using of deprecated approach.
I just checked your usecase and I didn’t get the behavior you described.
Please try again in this order and let us know if the error persists:

Backendless.setupDevice({
   "uuid": "753bc5dd3b5228c3",
   "platform": "Android",
   "version": "7.0"
})

Backendless.Messaging.registerDevice(/* your args here: deviceToken, channels, expiration */)

Regards,
Stanislaw

Hi Stanislaw
Thanks for prompt response.

You are right , it is not the setupDevice but the registerDevice

I am calling it only with device token argument (I understand the other are optional)

Backendless.Messaging.registerDevice(deviceToken);

and I get

JS: The sync methods of the Backendless API are deprecated and will be removed in the nearest future.
JS: Please, use async methods instead.

I didn’t find anything in the documentation about how to make this an async call though

Thank You,
Constantin

Now I was able to reproduce that issue, thank you for pointing this out!

I will fix it and release it soon, but for now I can suggest a temporary fix - add an empty array as the second argument: Backendless.Messaging.registerDevice(deviceToken, [])
This will not affect the logic of work.
I will inform you here when a new version of SDK with this fix is released.

Thanks & Regards,
Stanislaw

Thanks, I tried your suggestion and I now receive the registration id.

But when I send the push notification from backendless console I get this:

System.err: java.lang.RuntimeException: Unable to instantiate receiver com.backendless.push.BackendlessBroadcastReceiver: java.lang.ClassNotFoundException: Didn’t find class “com.backendless.push.BackendlessBroadcastReceiver” on path: DexPathList[[zip file “/data/app/com.leadingedge.bikecare-1/base.apk”],nativeLibraryDirectories=[/data/app/com.leadingedge.bikecare-1/lib/arm64, /data/app/com.leadingedge.bikecare-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]

Not sure if I should open a new thread but I guess this is related to having the backendless Android SDK/JAR file added to my nativescript application?

Regards,
Constantin

Yes, this is related to Android SDK.
Have you configured everything using this documentation?

https://backendless.com/docs/js/push_push_notification_setup_androi.html

The programm cannot find the class from androd sdk, which means that it is included incorrectly.

Regards,
Stanislaw

Yes, my app uses gradle and this is the dependency sections

dependencies {
** implementation ‘com.google.firebase:firebase-core:17.0.1’**
** implementation ‘com.google.firebase:firebase-messaging:19.0.1’**
** implementation group: ‘com.backendless’, name: ‘backendless’, version: ‘5.3.0’ **
** implementation ‘com.android.support:multidex:1.0.3’**
}

And the JAR is added in my App_Resource/Android/libs folder but during compile I get lots of duplicate class errors:

Duplicate class weborb.writer.specialized.TypedResultSet found in modules jetified-backendless-5.3.0.jar (backendless-5.3.0.jar) and jetified-backendless-5.3.0.jar (com.backendless:backendless:5.3.0)
** Duplicate class weborb.writer.specialized.TypedResultSetWriter found in modules jetified-backendless-5.3.0.jar (backendless-5.3.0.jar) and jetified-backendless-5.3.0.jar (com.backendless:backendless:5.3.0)**

And it just ocurred to me that this might come from the fact that I have the JS SDK also added to the application?

Thanks,
Constantin

Hi @Constantin_Craciunescu,

It appears that the backendless dependency is referenced twice. Could you please verify that?

Regards,
Mark

Hi Mark
Thanks for the hint, indeed something was not right with they way I did it

I will leave my solution here in case someone else has the same issue

I have placed the backendless-5.3.0.jar file into platforms\android\app\libs and in my app\App_Resources\Android\app.gradle


dependencies {
implementation ‘com.google.firebase:firebase-core:17.0.1’
implementation ‘com.google.firebase:firebase-messaging:19.0.1’
implementation files(‘libs/backendless-5.3.0.jar’)
implementation ‘com.android.support:multidex:1.0.3’
}

I am now able to receive push notifications.

Thank you for all your help

Constantin