-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
add Notification Service Extension #2105
Conversation
future question: can we also send/trigger local notifications from this function/extension? |
6234b38
to
3687246
Compare
570d07b
to
1c1ebb5
Compare
…f 'Notification Service Extension' to work
… the same files and assets as the main app
…orking in DcShare, sth. is missing)
…ked before without
…tle (iOS will truncate and the summary be sth as 'N messages in M chats')
…nding notifications
… each message; group everything in the same thread to avoid confusion when 'Alice Chat' is also present in thread 'Alice Chat, Bob Chat'
…in notifications not hitting the extension or handled by serviceExtensionTimeWillExpire
…iss all notifications on account switch, account switch is lightweight meanwhile
… saying 'Image' as on android is good enough. also, images may slow down things siginificantly as copied uncompressed in the existing implementation (nb: would be cool to show an emoji as '📷' instead of the string 'Image'
1c1ebb5
to
d928de7
Compare
…add at 'Build Phases / Copy Bundle Resources')
18db119
to
1449af8
Compare
use a simple 'Tap to open' as the notification content - usually, there was some message before/after or there are muted ones, so that openes less questions in most cases and makes at least a more sense than adding a Notification saying "No relevant things" :)
5a0da83
to
bea2abb
Compare
if so we could send a notification for each message that was received, but maybe that would spam too much. so the current way of telling about "you have multiple new messages" is completely fine, maybe even better 👀 |
i did a small test at some point, one can get a pointer to UNUserNotificationCenter from NSE, however, basic functionality as removing notifications did not work for me (otherwise one would not need an entitlement :) therefore, i did not investigate further, even if some hacks may work on some OS, this seems not to be the gist of the NSE, and there may be dragons now or in the future :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I added some questions here and there, but consider them feedback and feel free to just mark them as completed :)
this PR adds a "Notification Service Extension" that is called for every push notification received, allowing to modify the notification content, which is (localized) "You have new messages" otherwise.
as we do not know anything about the message the push notification belongs to (nor does apple or others then), we do a background-fetch over all accounts and change the notification accordingly, concretely setting title to chatname and title to message text beginning.
this also filters out reactions or other messages that do not come with DC_EVENT_INCOMING_MSG
if we get more than one message via IMAP (because of races or additional accounts), we use texts as "N messages" or "N messages in M chats".
because of that and because of muting, it may happen, that we do not want to display a notification at all. by default this is not possible (we can only downtune via sound, interruptionLevel, relevanceScore etc.), but there is a special entitlement that makes not displaying possible
nb: the "Notification Service Extension" is an own process (similar to DcShare), that is started independently of the main deltachat-ios app (which may or may not run at the same time). group-id makes it possible that the same data are accessible, however.
bigger todo parts:
finally:
before (showing generic "You have new messages" in german) / after (showing real message content):
successor of #2080