Action, onNotification not working with localNotification
See original GitHub issueHi and thanks for your work
I can’t get Action working, and even the onNotification parameter notify nothing.
Here is the code i put in my App.js componentDidMount there is the configuration and the action handler
componentDidMount() {
PushNotification.configure({
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification) {
console.log('NOTIFICATION:', notification);
},
popInitialNotification: true,
requestPermissions: true,
});
(function() {
PushNotificationAndroid.registerNotificationActions(['Lire']);
DeviceEventEmitter.addListener('notificationActionReceived', function(
action,
) {
console.log('Notification action received: ' + action);
const info = JSON.parse(action.dataJSON);
if (info.action === 'Lire') {
console.log('do the action');
}
// Add all the required actions handlers
});
})();
}
here is my function that i call to receive notification
const registerLocalNotification = article => {
const titre = he.decode(article.titre);
PushNotification.setApplicationIconBadgeNumber(0);
PushNotification.localNotification({
/* Android Only Properties */
vibrate: true,
vibration: 300,
priority: 'high',
visibility: 'public',
importance: 'high',
/* iOS and Android properties */
title: 'nouvel article',
message: titre, // (required)
playSound: false,
number: 1,
actions: '["Lire"]',
});
};
The notifications work fine but:
- when I click on the action button (on the notification message). Nothing is happening. I can’t see the console.log() in the DeviceEventEmitter.addListener method
- i can’t even see the console.log(‘NOTIFICATION:’, notification); in the PushNotification.configure method
My configuration is: react-native-cli: 2.0.1 react-native: 0.61.4 debian 10 and i test on emulated device with Android 9
Can someone tell me what do i miss ?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:13
Top Results From Across the Web
React native Push Notification onNotification event not working
for those asking for a solution, I did something like this in my app.js's componentDidMount method:
Read more >react-native-push-notification - npm
Read the troubleshooting guide before raising an issue. ... or local notification is opened onNotification: function (notification) ...
Read more >Sometime tapping on notification's… | Apple Developer Forums
Sometime tapping on notification's action button is not firing ... forLocalNotification: (UILocalNotification*) localNotification { //handle action here.. }.
Read more >How to use the react-native-push-notification.configure ... - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix ... when a remote or local notification...
Read more >Implementing React Native Push Notifications in Android Apps
Do note that, if you are not looking forward to using remote ... when a remote or local notification is opened or received...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Finally after changing some code directions. I made it work so sharing the code and have a look on it might helpful to you 😃
`var PushNotification = require(“react-native-push-notification”);
export class Participant extends React.Component {
}`
Hi @odnarb
Posting a single quote of code will not help to reproduce since it’s depend on many configuration (such as AndroidManifest, MainActivity, AppDelegate, …) Try to find the difference between exemple project or provide a reproducible exemple from exemple project.
As you may read in issues, this repository is open for maintainers, feel free to ask for it. I do not have enough time to maintain this project actually.
Regards