Backendless.Messaging.addPushNotificationListener is undefined (not a function)

Hi Guys, I’m following this post from @vladimir-upirov and I’m getting an error:

Backendless.Messaging.addPushNotificationListener is not a function … addPushNotificationListener is undefined) when added to my componentDidMount, couldn’t find a related topic here.

I presume I didn’t conclude and as a result, I’m able to Send but NOT Receive Notifications on Android. Any guess?

Note: “backendless”: “^5.2.0” installed and working perfectly. Regards

Android tutotrial: https://backendless.com/push-notifications-using-backendless-react-native-android/

Hi Marcio

Have you installed/imported this backendless-react-native npm module?

Regards, Vlad

this “addPushNotificationListener” method comes from here https://github.com/Backendless/React-Native-JS-SDK/blob/master/index.js#L41

Yes @vladimir-upirov, and for sure its working properly. I’m using it in a lot of different functions across the App. Ok, thanks I’ll make a few changes.

there are should be two imports of JS-SDK and Patch

import Backendless from 'backendless'
import 'backendless-react-native'

@MARCIO_PRUDENCIO is the problem resolved now?

Still working on that @mark-piller, not yet. Making a few tests and I notice that all my Android devices and simulator gets the same DeviceToken, (different deviceId tough) it’s that normal on Android or is a device register error? On iOS, we don’t get on the emulator. Regards

Device token comes from FCM, not us, so this would be a better question for Google.

Hi @MARCIO_PRUDENCIO
did you follow step-by-step by this article https://backendless.com/push-notifications-using-backendless-react-native-android/

There is a paragraph for installing this backendless-react-native module, the module contains native android implementation for PushNotifications

Hi @vladimir-upirov according to this article (https://github.com/Backendless/React-Native-JS-SDK) 3 modules are required in order to work.

  1. backendless-react-native
  2. react-native-push-notification
  3. react-native-device-info (already installed)

Wondering this (react-native-push-notification) is really mandatory? 'Cause is not mentioned in the first article.

no, these two modules are no longer needed, the readme is out of date, I’ll fix it today, sorry for that,
For now you can just follow by steps from the article, there are the latest instructions
Regards, Vlad

That’s great @vladimir-upirov, fewer modules are always better.
I believe it will require changes in my initApp.

react

have you run “react-native link” ?

Could be a linking issue @vladimir-upirov , that’s why I like to link manually. I always have a problem linking Android.

The linking process added backendless-react-native only on settings.gradle, It should have more… I need to proceed manually. Do you have any manually linking reference?

I don’t have steps to link it manually, at least for now,

but here is a commit after installing/linking the “backendless-react-native” module https://github.com/Valodya/backendless-react-native-example/commit/daa865e1999caea2f7d5dbe4e6970e21113c7cae , as you can see there aren’t many changes

That helps a lot. Thanks @vladimir-upirov.

good, let me know about any issues and I will be happy to help you with the backendless-react-native package

1 Like

Hi @vladimir-upirov I couldn’t make it work, to start it brought a few changes in my Gradle and after solve all build errors when finally went through the build the App crashes after few sec. I removed the RNBackendless lines from MainApplication and Build.gradle and the App runs just fine.

I had no issue on iOS, altough was already working fine just with PushNotificationIOS. Don’t need backendless-react-native in order to work on iOS. Still looking to make it work on Android. Regards

Hi Marcio
Could you share with us errors what you had or create a simple app to reproduce the issue and send it to support@backendless.com
Regards, Vlad

Hi Marcio, as far as I know the server after sending PN cleans up all the invalid device registrations from the table

Regards, Vlad

1 Like