react-native-push-notification: undefined is not an object (evaluating 'RNPushNotification.presentLocalNotification')
Hello,
I setup react-native-push-notification according the Readme, but when i use the localNotification like this:
var PushNotification = require('react-native-push-notification');
PushNotification.localNotification({
message: 'My notification message'
});
I have this error:
undefined is not an object (evaluating 'RNPushNotification.presentLocalNotification')
Have you some idea about this ?
My react native version: 0.36
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 28 (4 by maintainers)
Commits related to this issue
- Add the npm --save flag in the installation section. As discusssed in #318. Fixes #361 — committed to j-nolan/react-native-push-notification by j-nolan 7 years ago
- Add the npm --save flag in the installation section. As discussed in #318. Fixes #361 — committed to j-nolan/react-native-push-notification by j-nolan 7 years ago
- Merge branch 'master' into develop * master: Update package.json Update ReactNativePushNotificationPackage.java made the conversion from `details.number` to applicationIconBadgeNumber in the io... — committed to 3sidedcube/react-native-push-notification by deleted user 7 years ago
- Merge branch 'develop' into feature/rfu * develop: Update package.json Update ReactNativePushNotificationPackage.java made the conversion from `details.number` to applicationIconBadgeNumber in ... — committed to 3sidedcube/react-native-push-notification by deleted user 7 years ago
Apparently i have the same problem, with a different message: undefined is not an object (evaluating RNPushNotification.getInitialNotification)
Any ideas?
I have the same issue
i had the same issue. Fixed after running
react-native run-androidin the terminal.Always the same đ I just recheck readme and trouble shooting guide, i do react-native link, and in settings.gradle :
in build.gradle:
In the MainApplication.java the package is imported
and i verified that package has been added in react package list
Also, i run the application in my physical devise and i sure that this package are correctly linked.
Do you think it is surely a version issue ?
The issue I faced- âundefined is not an object (evaluating RNPushNotification.getInitialNotification)â. The reason- I was trying to integrate the library while using expo for running project which is not supported. You will have to eject your project using âreact-native initâ. Doing so worked for me. Strange thing is no one has mentioned that it will not work with expo as a lot of people use expo for development of their mobile apps.
After running react-native link, I received this error:
Update: I had to add the following into my build.gradle file:
but now it gives me the same error:
undefined is not an object (evaluating RNPushNotification.getInitialNotification)Doesnât seem like this issue should be closedâŚ
Can confirm running
react-native run-androidafterreact-native linkcommand solves the issueI was having this problem just a minute ago. i did
react-native linkand the output said the notification lib was linked⌠but I needed to modify MainActivity anyway.Make sure you import it like this
import PushNotification from 'react-native-push-notifications';(no brackets). Or whatever the OneSignal class is (Iâm not using it for OneSignal, so Iâm not sure how that works in this library). Also just follow the setup documentation slowly and carefully, if you follow all of the steps it will work. If it still doesnât work, just post your manifest here and your JavaScript and someone will identify the issue.Just had the same issue, it was because
react-native linkdid not addnew ReactNativePushNotificationPackage()inMainApplication.java, adding it manually made it work.sounds like youâve not linked youâre project correctly. Please recheck the readme and the trouble shooting guide.