Add ability to respond to notifications on macOS
Implement the UNTextInputNotificationAction
and UNNotificationCategory
stuff so that messages can actually be sent from the notification banner.
This requires adding a UNUserNotificationCenterDelegate
object to respond to notification actions. This needs to be registered when the app launches (rather than when we receive a notification), so I have updated main.cpp to incorporate this. If there's a better way... let me know.
I also now properly check for permission access before trying to send a notification. I'm pretty sure it ends up as a no-op if you don't have permission, rather than a hard error, but I'd rather not waste cycles constructing a notification that will never see the light of day if it's not necessary!
Merge request reports
Activity
requested review from @deepbluev7
added 54 commits
-
69bad029...9c3ca956 - 53 commits from branch
master
- 16630359 - Merge nheko-im/master and fix .clang-format conflicts
-
69bad029...9c3ca956 - 53 commits from branch
added 124 commits
-
16630359...b92a3b8d - 121 commits from branch
master
- 5cc815b2 - Add ability to respond to notifications on macOS
- 04b40a3c - Add license headers to files
- 32d67426 - Add implementation of replies via notification on macOS
Toggle commit list-
16630359...b92a3b8d - 121 commits from branch
added 1 commit
- 9c67f05d - Use correct styling since my clang format is old
- src/notifications/MacNotificationDelegate.h 0 → 100644
- src/notifications/NotificationManagerProxy.h 0 → 100644
166 void NotificationsManager::attachToMacNotifCenter() 96 167 { 97 } 168 UNUserNotificationCenter* center = 169 [UNUserNotificationCenter currentNotificationCenter]; 98 170 99 void 100 NotificationsManager::notificationReplied(uint, QString) 101 { 102 } 171 std::unique_ptr<NotificationManagerProxy> proxy = std::make_unique<NotificationManagerProxy>(); 103 172 104 void 105 NotificationsManager::notificationClosed(uint, uint) 106 { 173 connect(proxy.get(), &NotificationManagerProxy::notificationReplied, ChatPage::instance(), &ChatPage::sendNotificationReply); 105 NotificationsManager::notificationClosed(uint, uint) 106 { 173 connect(proxy.get(), &NotificationManagerProxy::notificationReplied, ChatPage::instance(), &ChatPage::sendNotificationReply); 174 175 MacNotificationDelegate* notifDelegate = [[MacNotificationDelegate alloc] initWithProxy:std::move(proxy)]; 176 177 center.delegate = notifDelegate; 107 178 } 108 179 109 void 110 NotificationsManager::removeNotification(const QString &, const QString &) 111 {} 180 // unused 181 void NotificationsManager::actionInvoked(uint, QString) { } 182 183 void NotificationsManager::notificationReplied(uint, QString) { } I feel like these needed to be defined or you ended up with symbol errors. I don't remember though, it's been a while since these bits were first added. The functions in question are only relevant for dbus, but your comment in the other file says that signals can't be in ifdefs. so here we are.
mentioned in commit a6f53699