Notifications Enabled (#760)

* Notifications Enabled with default static text

notifications enabled with default static text

code improvement

added the share key

* added the changelog

* notification ID is added to the json only if it exists

* renamed Bundle.mainApp to app and updated the strings from localazy

* made a struct for the APNSPayload

* APNS Payload fix
This commit is contained in:
Mauro
2023-04-05 20:16:30 +02:00
committed by GitHub
parent 8a56649289
commit 0bce9918e6
18 changed files with 146 additions and 46 deletions
@@ -36,11 +36,13 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
guard !DataProtectionManager.isDeviceLockedAfterReboot(containerURL: URL.appGroupContainerDirectory),
let roomId = request.roomId,
let eventId = request.eventId,
let credentials = keychainController.restorationTokens().first else {
let notificationID = request.pusherNotificationClientIdentifier,
let credentials = keychainController.restorationTokens().first(where: { $0.restorationToken.pusherNotificationClientIdentifier == notificationID }) else {
// We cannot process this notification, it might be due to one of these:
// - Device rebooted and locked
// - Not a Matrix notification
// - User is not signed in
// - NotificationID could not be resolved
return contentHandler(request.content)
}
@@ -53,7 +53,6 @@ extension NotificationItemProxy {
/// - Returns: A notification content object if the notification should be displayed. Otherwise nil.
func process(with roomId: String,
mediaProvider: MediaProviderProtocol?) async throws -> UNMutableNotificationContent? {
nil
// switch timelineItemProxy {
// case .event(let eventItem):
// guard eventItem.isMessage else {
@@ -73,6 +72,9 @@ extension NotificationItemProxy {
// case .other:
// return nil
// }
// For now we can't solve the sender ID nor get the type of message that we are displaying
// so we are just going to process all of them as common
try await processCommon(senderId: "undefined", roomId: roomId, mediaProvider: mediaProvider)
}
// MARK: - Private
@@ -29,4 +29,8 @@ extension UNNotificationRequest {
var unreadCount: Int? {
content.userInfo[NotificationConstants.UserInfoKey.unreadCount] as? Int
}
var pusherNotificationClientIdentifier: String? {
content.userInfo[NotificationConstants.UserInfoKey.pusherNotificationClientIdentifier] as? String
}
}