ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.04k stars 999 forks source link

feat: Combine LocalNotification and PushNotifications or Notifications Actions in background #4146

Closed spennyf closed 7 months ago

spennyf commented 3 years ago

Feature Request

Description

I would like to be able to send a push notification with a category set on iOS and then have those actions appear on the notification on the device (so far I can do this), and then be able to click that action and run code without the app being brought to the foreground.

Platform(s)

iOS

Preferred Solution

I should be able to set up a listener that when the action is clicked the listener will be called and my code executed

Alternatives

I have tried setting this up with both LocalNotifications and PushNotifications, and I can remotely send an notification and specify the category so I see the actions show up, but unless I set the action as foreground: true no code is executed

Additional Context

digaus commented 3 years ago

Afaik it is not possible to execute start the webview in the background. You would need to implement "Notification Service Extension" in Swift for iOS but again, you can only execute code there and not inside the webview.

spennyf commented 3 years ago

@digaus thank you for the reply, I am quite sure it can be done as this plugin does it firebasex and I have looked though the swift logic of firebasex and capacitor and when I look at this file and section of code where it would be handled in capacitor CAPUNUserNotificationCenterDelegate.swift it looks like there was some logic written but then the completionHandler () is called at the start of the function so none of the logic is executed that is on v2.4.6 and I just looked at main branch and it looks like the plugins have been reorganized and there is some work being done to handle it here possibly by @ikeith and @dwieeb, maybe they will be able to provide some insight if this feature is coming?

jcesarmobile commented 7 months ago

WKWebView pauses the javascript execution as soon as the app is put into the background

There is a new plugin for executing javascript in the background, but outside the WKWebView that might do what you need https://github.com/ionic-team/capacitor-background-runner

If still doesn't work you can request the feature there. Closing it here since the plugins are not part of Capacitor itself anymore but separate packages.

ionitron-bot[bot] commented 6 months ago

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.