fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.48k stars 1.36k forks source link

iOS notifications only work in the foreground #4971

Open Gys opened 2 months ago

Gys commented 2 months ago

Checklist

Is your feature request related to a problem?

IOS notifications are working in the latest develop branch. The app asks correctly if notifications are allowed to show. But then notifications are shown only while the app is running in the foreground.

If I create a notification to be shown a few seconds later and send the app to the background nothing happens. Only going back to the app will trigger showing the notification (which can be much later or never).

Is it possible to construct a solution with the existing API?

This might be related to some bug or configuration problem on iOS.

Describe the solution you'd like to see.

On Android this works correctly: even while an app is in the background, notifications from that app will be shown at the required moment.

Only showing notifications while the app is in foreground is not very useful. The app already has full attention.

Jacalz commented 2 months ago

Duplicate to or related to https://github.com/fyne-io/fyne/issues/3656 possibly?

Gys commented 2 months ago

That issue is about remote push notifications and mobile in general. This issue is about local push notifications and specific for iOS only. This works on platforms like Darwin and Android, but not for iOS.

andydotxyz commented 2 months ago

It's not related to whether the app is foregrounded but whether it is running according to the OS (as I understand it anyhow). We don't have any background service support so as soon as the OS suspends your app the code won't run and notifications won't send.

Gys commented 2 months ago

I am sure there is no background processing possible on iOS. The only thing coming close is sending a silent remote push notification which 'wakes up' the app for a moment (if the OS chooses to allow it). At that moment the app can do things in the background.

@andydotxyz You mentioned elsewhere that on mobile notifications would be shown if the app was in the background. So that is only for Android then.

Sorry, I was hoping I missed something about local notifications on iOS. So this indeed related to https://github.com/fyne-io/fyne/issues/3656

PS: it is possible to setup a local notification with a specific 'show' time and date on both iOS and Android. This is not exposed by Fyne though.

andydotxyz commented 2 months ago

The app can send notifications if it is running in the background on iOS and Android. However (depending on memory pressure) the iOS app will likely be killed in seconds rather than minutes on Android.

Scheduling notifications is an intended improvement so feel free to open a PR or feature request so we can track its addition.