blob: ddc5816c5a3439b57325a395fb4a4a290dfe241d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#import "notifications/MacNotificationDelegate.h"
#include <QString>
#include "ChatPage.h"
@implementation MacNotificationDelegate
- (id)initWithProxy: (std::unique_ptr<NotificationManagerProxy>&&)proxy
{
if(self = [super init]) {
mProxy = std::move(proxy);
}
return self;
}
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void (^)())completionHandler
{
if ([response.actionIdentifier isEqualToString:@"ReplyAction"]) {
if ([response respondsToSelector:@selector(userText)]) {
UNTextInputNotificationResponse* textResponse = (UNTextInputNotificationResponse*)response;
NSString* textValue = [textResponse userText];
NSString* eventId = [[[textResponse notification] request] identifier];
NSString* roomId = [[[[textResponse notification] request] content] threadIdentifier];
mProxy->notificationReplied(QString::fromNSString(roomId), QString::fromNSString(eventId), QString::fromNSString(textValue));
}
}
completionHandler();
}
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
completionHandler(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound);
}
@end
|