Closed naveedahmed1 closed 4 years ago
This is by design. Sending only data payload will not display a notifiation. The Phonegap Push Plugin has a custom implementation where it will display data payloads if they have a title and body
I created a plugin where you can customize if you want to show the notification. Currently only can set title and body. You could create your own Plugin which handles this.
Thanks for sharing this @digaus, any idea about showing Actions buttons on push notifications when using Capacitor?
Thanks for sharing this @digaus, any idea about showing Actions buttons on push notifications when using Capacitor?
Yes you could modify notification builder here: https://github.com/digaus/capacitor-background-fcm/blob/5e075162114c6e8bfd22d82da0bd488eb2d827ad/android/capacitor-background-fcm/src/main/java/com/digaus/capbackgroundfcm/BackgroundFCMService.java#L93
There you could include addAction with its own intent. I could modify my plugin to be able to include action buttons but currently am too busy.
It would be really great, if you could please also add support for Action Buttons.
I proposed Action Buttons as a feature for Capacitor Push Plugin as well.
https://github.com/ionic-team/capacitor/issues/1938
What if you could add the functionality in the original Capacitor Plugin? I had a brief conversation with @mhartington here https://twitter.com/mhartington/status/1171070552519389184 and it seems that the Capacitor team would also support such contribution.
Any update on this?
as digaus said, this is by design, data notifications are not shown, you can use LocalNotifications plugin to show a notification once the data is received
as digaus said, this is by design, data notifications are not shown, you can use LocalNotifications plugin to show a notification once the data is received
You can't, as when the app is in the background, none of the code triggers. When it's in the foreground it works but not in the background.
https://github.com/ionic-team/capacitor/issues/1938 should be re-opened as it is a legitimate feature request.
as digaus said, this is by design, data notifications are not shown, you can use LocalNotifications plugin to show a notification once the data is received
You can't, as when the app is in the background, none of the code triggers. When it's in the foreground it works but not in the background.
1938 should be re-opened as it is a legitimate feature request.
That's not true. The WebView/JavaScript code does not get triggered. However you can still show a local notification if you program it yourself. Just check out my old plugin on how to achieve this.
Always starting the WebView just to handle the data is not a good solution and should not be done.
as digaus said, this is by design, data notifications are not shown, you can use LocalNotifications plugin to show a notification once the data is received
You can't, as when the app is in the background, none of the code triggers. When it's in the foreground it works but not in the background.
1938 should be re-opened as it is a legitimate feature request.
That's not true. The WebView/JavaScript code does not get triggered. However you can still show a local notification if you program it yourself. Just check out my old plugin on how to achieve this.
Always starting the WebView just to handle the data is not a good solution and should not be done.
I will give your repo a try today. It says that you need to get your hands on a Mac for ios. I can provide you with my Mac VM via Remote Control? Or if you don't wish to, I can assist you in getting your own Mac VM up and running on your end.
@digaus When trying to follow your instructions for "on your MainActivity.java file add import com.digaus.capbackgroundfcm.BackgroundFCM;" I get the below:
Let me know if I am doing something stupid.
@digaus I tried building and running the app without the MainActivity.java changes and received the below:
App just shows a white screen with nothing loading.
I see that the main files/folders for your repo were changed some time ago. Perhaps it no longer works in the latest release?
Anyhoo, waiting on your feedback.
I also noticed that you don't have instructions for add listener push notification received. Only action performed?
@digaus Ignore my previous messages. I will put this aside for now and forget about LocalNotifications as a workaround. It would appear that https://github.com/ionic-team/capacitor-plugins/issues/200 has been moved to "On deck ⚾ in Capacitor Engineering ⚡️" 6 days ago
https://github.com/ionic-team/capacitor-plugins/issues/200. is not w3orking.
{ "to":"fTrG6-1RQJSJCfIawLYHUy:APA91bHa9JbyDBDSSGqTEhMT6VIWXRFdh_xBtUTF-Rd9WUBHpOLsTi4xZsFUZMFW7S8ZQHLJooHB00XMxj8uUiFvKztNbia0ObTOfL6buI3zBOgYsR3PmNQRquKWUNzq4Cg3E93BPw9n", "notification" : { "body" : "Hiii Survey", "title": "Survey APP Notification" }, "data" : { "surveyId": "53cab4f8-da84-4925-aad0-0bf82401df34", "title":"Test mapping issue" } }
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Description of the problem: When using Capacitor Push Notification Plugin, the notification is received when the app is in foreground (opened and running) but when app is in background i.e. closed or minimized no notification is displayed in notification center. When I launch app, the notification is shown there.
Affected platform
OS of the development machine
Capacitor version: 1.2.0
node version: 10.16.0
Steps to reproduce:
When using Capacitor Push Notification Plugin, the notification is received when the app is in foreground (opened and running) but when app is in background i.e. closed or minimized no notification is displayed in notification center. When I launch app, the notification is shown there.
Below the is notification data that I am sending from server:
This works perfectly fine with Firebase plugin for web that I am currently using for my webstie as well as it works without any issue with cordova push notification plugin https://github.com/phonegap/phonegap-plugin-push.
I am following the official guide to setup push notifications https://capacitor.ionicframework.com/docs/guides/push-notifications-firebase/ and have below code in my app: