React-native-notifications: [V3.0.0][ANDROID] TypeError: null is not an object (evaluating 'this.nativeCommandsModule.refreshToken')

Created on 15 Jan 2020  Â·  21Comments  Â·  Source: wix/react-native-notifications

as the title said. I am using the newest version of the module on Android. but I got this error when calling Notifications.registerRemoteNotifications

The error is: TypeError: null is not an object (evaluating 'this.nativeCommandsModule.refreshToken')

My package.json

"react": "16.9.0",
"react-native": "0.61.2",
"react-native-notifications": "^3.0.0",

Please fix the problem! I really appreciate it!!!

Most helpful comment

Hmm.. Im not too sure. I forgot to add this part and after adding it, it worked for me.

In MainApplication.java

import com.wix.reactnativenotifications.RNNotificationsPackage;

protected List<ReactPackage> getPackages() {
  ...
  packages.add(new RNNotificationsPackage(MainApplication.this));
  return packages;
}

All 21 comments

I am getting undefined:
TypeError: Cannot read property 'refreshToken' of undefined

I am getting undefined:
TypeError: Cannot read property 'refreshToken' of undefined

This usually means, that you have not properly linked the native module for the current platform OS.

Confirmed that the problem is about linking

I think that I have already well linked, but showing this error anyway.
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-notifications": "3.1.1",

How is this issuel solved?

@bduyng was right. It was a linking issue.

yeah, I know. But how can I solve it?
Autolinking seems to be not working. I follow this steps, to link manually: https://github.com/wix/react-native-notifications/issues/447#issuecomment-576744535
But I continue having the same error in Android.

Hmm.. Im not too sure. I forgot to add this part and after adding it, it worked for me.

In MainApplication.java

import com.wix.reactnativenotifications.RNNotificationsPackage;

protected List<ReactPackage> getPackages() {
  ...
  packages.add(new RNNotificationsPackage(MainApplication.this));
  return packages;
}

Wow! thanks so much! I was adding that line, but not right. So stupid...

You save my day, making me see that concrete line carefully. Thanks a lot!

I am facing the same problem can you provide the full sample code of your solution especial that linking part i am stuck here @JaioSkura

Hi @lylest
What react-native version are you using? and what react-native-notifications version? In my case, with :
"react-native": "0.61.5",
"react-native-notifications": "3.1.4"

you don't need to do anything special. This solution was for 3.1.1 but with the actual version the autolink feature works right.

Let me know!

iIam using
"react-native": "0.62.2",
"react-native-notifications": "^3.1.4", "react-native-notifications": "^3.1.4",
it doesn't work or should I remove manual linking that i have set i am facing the same problem exactly as above screen shots

Hi, I would try removing manual linking yes.

failed with same error as on the screen shot above

I haven't try with RN 0.62, but is strange having a regresion in that sense. Do you have somewhere manually included the library? build.gradle, settings.gradle or mainAplication.java?
If so delete, clean , i would remove build folder too, and rebuild all.

let Cross check again and try to clean and build again

On Wed, Apr 29, 2020, 11:21 AM JaioSkura notifications@github.com wrote:

I haven't try with RN 0.62, but is strange having a regresion in that
sense. Do you have somewhere manually included the library? build.gradle,
settings.gradle or mainAplication.java?
If so delete, clean , i would remove build folder too, and rebuild all.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/wix/react-native-notifications/issues/440#issuecomment-621059215,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AIFSPYSRZXXRL2K4Y4SAEW3RO7PO5ANCNFSM4KHHXZDA
.

I FOLLOWED THE DOCS STEP BY STEP BUT STILL HAVE THIS ISSUE I TRIED AUTO LINKING AND MANUAL LINKIG BUT NONE OF THEM WORK ANY UPDATED SOLUTION FOR THIS ISSUE

Witch versions of react-native and react-native-notifications are you using?

I tried all these ideas, without success.

"react-native": "0.62.2",
"react-native-notifications": "^3.2.2",

Having the same error displayed on the screenshot. Tried cleaning folders and chaces, rebuilding, resyncing and no luck.

I actually failed to implement notifications for my app the documentations
are awful and most videos are outdated

On Thu, Jul 9, 2020, 10:42 PM Miguel Moronta notifications@github.com
wrote:

I tried all these ideas, without success.

"react-native": "0.62.2",
"react-native-notifications": "^3.2.2",

Having the same error displayed on the screenshot. Tried cleaning folders
and chaces, rebuilding, resyncing and no luck.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/wix/react-native-notifications/issues/440#issuecomment-656315113,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AIFSPYQEJY23ZFNJBHZYYD3R2YMSBANCNFSM4KHHXZDA
.

Fine, giving a try to https://github.com/zo0r/react-native-push-notification in that case.

Thanks,

Manually linking react-native-notifications and adding this bit to react-native.config.js solved it for me on our react-native 0.61.0 app.

  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
Was this page helpful?
0 / 5 - 0 ratings

Related issues

daominhsangvn picture daominhsangvn  Â·  6Comments

veedeo picture veedeo  Â·  6Comments

codoffer picture codoffer  Â·  5Comments

ghost picture ghost  Â·  3Comments

Mimble-Wimble picture Mimble-Wimble  Â·  3Comments