I am not able to differ background push notification from foreground push notification
See original GitHub issueHello.
I have the plugin implementation just like the following.
PushNotifications.register();
PushNotifications.addListener('registration', (token: PushNotificationToken) => {
// registering token on my backend
});
PushNotifications.addListener('registrationError', (error: any) => {
console.log('error on register ', JSON.stringify(error));
});
PushNotifications.addListener('pushNotificationReceived', (notification: PushNotification) => {
// receive push notification (opened application)
console.log('notification', notification.data);
});
PushNotifications.addListener('pushNotificationActionPerformed', (notification: PushNotificationActionPerformed) => {
// never called
console.log('notification action performed', notification);
});
When i receive the push notification with the app opened (foreground), my console.log is executed as expected. But, if the app is closed, when i tap the notification, the app become open, but none of ther listeners are fired.
Am i doing something wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
Flutter Firebase foreground push notification not showing but ...
After struggling a lot with this I found the solution. The problem was that I was sending the message ...
Read more >Firebase Notifications in Background & Foreground in Android
The problem you have now is that your onMessageReceived is ONLY called when the app is in foreground, if you app if is...
Read more >Push Enablement and Subscription - Braze
Foreground push provides the ability to send regular visible push notifications to the foreground of a user's device. · Background push is available...
Read more >Foreground services - Android Developers
Foreground services perform operations that are noticeable to the user. Foreground services show a status bar notification, so that users are actively aware ......
Read more >Receive messages in a Flutter app - Firebase - Google
On iOS, if the user swipes away the application from the app switcher, it must be manually reopened for background messages to start...
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 Free
Top 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
@FinnBossen yes. If you add this to your capacitor config file:
"plugins": { "PushNotifications": { "presentationOptions": ["badge", "sound", "alert"] } }
then remove the options you wish to have disabled for foreground notifications.
https://capacitor.ionicframework.com/docs/apis/push-notifications
@gusmarra now it’s working for me: