Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show message content in iOS push notification #49

Open
krille-chan opened this issue Jul 15, 2023 · 13 comments
Open

Show message content in iOS push notification #49

krille-chan opened this issue Jul 15, 2023 · 13 comments

Comments

@krille-chan
Copy link
Owner

Description

I am not quite sure if this feature is available on Android already, but it is a major quality of life feature. It would be nice to see the content of the message in the push notification. If the app is in the foreground, this already works, but if not I just get a generic message.

Additional information:

  • Device: iPhone 12 mini
  • OS and OS version:iOS 14.4.1
  • Installed version of FluffyChat: 0.27.0
@Damaj301damaj-lol
Copy link

Can confirm, text preview is available over android with a unifiedpush provider such as ntfy, don't know about anything else :p

@mietzen
Copy link

mietzen commented Sep 1, 2023

This does not solve the problem, but might also be interesting:
iOS (lock)screen widget with flutter and swift

Found it here: https://www.reddit.com/r/FlutterDev/comments/xgxh3d/ios_16_lock_screen_widgets_with_flutter/

@step21
Copy link

step21 commented Nov 2, 2023

Supposedly - at least according to some older blog posts this works or at least used to work on element/riot.im

@snowkat
Copy link

snowkat commented Nov 2, 2023

A Notification Service Extension is required to provide message content without including message content in the APNs payload.1 I've wanted to work on a PR for this, but since a paid developer certificate is needed even for Simulator testing, I haven't gotten far yet.

On the technical side, the main challenge is with how Notification Service Extensions run: effectively as a different program with similar filesystem access to the main app. There's no IPC with the main app—after all, it might be closed or backgrounded.

Since API and storage is handled in the Flutter VM, either that access would need to be replicated in Swift—especially for Hive, this would be a significant effort—or there'd have to be some way to safely start up the Flutter VM on the off-chance the main app is still running. I'm not familiar enough with Flutter's internals to say if this is possible or how easy it is.

Footnotes

  1. This is how Element X iOS presents notifications: https://github.com/vector-im/element-x-ios/blob/develop/NSE/Sources/NotificationServiceExtension.swift

@step21
Copy link

step21 commented Nov 2, 2023

Thanks for the info. If it's about funding for a certificate, I would be up to help. I haven't coded reasonable amounts of Swift nor Flutter, so I cannot really help with that. I didn't know about element X iOS, I might try that.

@snowkat
Copy link

snowkat commented Nov 19, 2023

I've gotten a setup to test out Notification Service Extension and wanted to share some of my notes. Since I didn't mention previously: the main reason I'm focusing on an NSE and not flutter_local_notifications (which uses UNUserNotificationCenterDelegate, I believe?) is to handle notifications when the app is killed. That said, maybe it's best to handle any cases rather than none, so I'll look at that side again.

As of Flutter 3.16.0, you can properly embed an extension-safe version of the Flutter framework in app extensions—see flutter/flutter#16092 (comment) and this doc. The latter is more focused on Share extensions, but does note this:

Due to the memory limitations of app extensions, it is only recommended to use Flutter to build app extension UI for extension types that have memory limits larger than 100MB. For example, share extensions which have a 120MB memory limit.

Frustratingly, these limits aren't officially documented anywhere. Testing on my end has shown the limit for an NSE to be 24 MB:

fluffychat.1.ui (5): EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=24 MB)

So in the case of the app being in a killed state, I'm not sure how far one could get without something like matrix-org/matrix-ios-sdk to get the room/event data—and that doesn't account for E2EE.

@predictron-cloud
Copy link

predictron-cloud commented Dec 2, 2023

@predictron-cloud
Copy link

image
On my iPhone with debug I see that the error is only here ^^. It just cannot load the matrix client.

@lboklin
Copy link

lboklin commented Dec 11, 2023

I don't get message content (or anything informative, really) on LineageOS (unified push) either.

Copy link

This issue is stale because it has been open for 120 days with no activity.

@github-actions github-actions bot added the stale The item is going to be closed soon because of inactivity label Apr 10, 2024
@Mikaela
Copy link
Collaborator

Mikaela commented Apr 13, 2024

I think this is still the case

@github-actions github-actions bot removed the stale The item is going to be closed soon because of inactivity label Apr 14, 2024
@LuNeder
Copy link

LuNeder commented Apr 27, 2024

On the technical side, the main challenge is with how Notification Service Extensions run: effectively as a different program with similar filesystem access to the main app. There's no IPC with the main app—after all, it might be closed or backgrounded.

Since API and storage is handled in the Flutter VM, either that access would need to be replicated in Swift—especially for Hive, this would be a significant effort—or there'd have to be some way to safely start up the Flutter VM on the off-chance the main app is still running. I'm not familiar enough with Flutter's internals to say if this is possible or how easy it is.

If I understand it correctly, Signal’s notifications just wake up the main app and then it looks for stuff on the servers on its own. This is done to avoid leaking messages to Apple or Google servers through the notifications, but maybe it could also help here? Also not sure wether Signal users flutter, so I do apologize if my message is useless.
I’m pretty sure they made an announcement about this back when there was that whole “apple leaking notifications to the usa government” scandal, but tbh I couldn’t find it. The only place I could find mentioning this was an old reddit post linking to this file which shows the server-side implementation, but the iOS side of stuff must be somewhere in their github too.

@zha0yangchen
Copy link

still not work on iOS 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants