Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarino Faggiana <m.faggiana@twsweb.it>2018-07-27 19:06:54 +0300
committerMarino Faggiana <marinofaggiana@mbp-di-marino.homenet.telecomitalia.it>2018-07-27 19:06:54 +0300
commit072f877ee651570aa67e2425ed906a9f3531b355 (patch)
treeb8880b38c7f2dcb1ed3aad318c1aabfdfb1b9f56 /Notification Service Extension
parent4e877f33b0ee168b9af86442eca32cd50f781f84 (diff)
Add NotificationService
Diffstat (limited to 'Notification Service Extension')
-rw-r--r--Notification Service Extension/NotificationService.swift30
-rw-r--r--Notification Service Extension/NotificationServiceExtension-Bridging-Header.h31
2 files changed, 59 insertions, 2 deletions
diff --git a/Notification Service Extension/NotificationService.swift b/Notification Service Extension/NotificationService.swift
index c98aef9bf..dc9cfd8aa 100644
--- a/Notification Service Extension/NotificationService.swift
+++ b/Notification Service Extension/NotificationService.swift
@@ -5,6 +5,21 @@
// Created by Marino Faggiana on 27/07/18.
// Copyright © 2018 TWS. All rights reserved.
//
+// Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
import UserNotifications
@@ -14,12 +29,23 @@ class NotificationService: UNNotificationServiceExtension {
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
+
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
- // Modify the notification content here...
- bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
+
+ bestAttemptContent.title = "Nextcloud notification 🔔"
+ bestAttemptContent.body = ""
+
+ let message = bestAttemptContent.userInfo["subject"] as! String
+
+ guard let decryptedMessage = NCPushNotification.sharedInstance().decryptPushNotification(message, withDevicePrivateKey: CCUtility.getPushNotificationPrivateKey()) else {
+ contentHandler(bestAttemptContent)
+ return
+ }
+
+ bestAttemptContent.body = decryptedMessage
contentHandler(bestAttemptContent)
}
diff --git a/Notification Service Extension/NotificationServiceExtension-Bridging-Header.h b/Notification Service Extension/NotificationServiceExtension-Bridging-Header.h
new file mode 100644
index 000000000..348390837
--- /dev/null
+++ b/Notification Service Extension/NotificationServiceExtension-Bridging-Header.h
@@ -0,0 +1,31 @@
+//
+// NotificationServiceExtension-Bridging-Header.h
+// Nextcloud
+//
+// Created by Marino Faggiana on 27/07/18.
+// Copyright © 2018 TWS. All rights reserved.
+//
+// Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#import "CCUtility.h"
+#import "NCPushNotification.h"
+
+#import "OCActivity.h"
+#import "OCUserProfile.h"
+#import "OCCapabilities.h"
+#import "OCExternalSites.h"
+#import "OCSharedDto.h"