mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
Merge branch 'voip_group_notification' into voip_design_updates
This commit is contained in:
@@ -323,6 +323,20 @@ Matrix session observer used to detect new opened sessions.
|
|||||||
|
|
||||||
#pragma mark - UNUserNotificationCenterDelegate
|
#pragma mark - UNUserNotificationCenterDelegate
|
||||||
|
|
||||||
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
|
||||||
|
{
|
||||||
|
if (notification.request.content.userInfo[Constants.userInfoKeyPresentNotificationAlways])
|
||||||
|
{
|
||||||
|
completionHandler(UNNotificationPresentationOptionBadge
|
||||||
|
| UNNotificationPresentationOptionSound
|
||||||
|
| UNNotificationPresentationOptionAlert);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
completionHandler(UNNotificationPresentationOptionNone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// iOS 10+, see application:handleActionWithIdentifier:forLocalNotification:withResponseInfo:completionHandler:
|
// iOS 10+, see application:handleActionWithIdentifier:forLocalNotification:withResponseInfo:completionHandler:
|
||||||
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,9 +16,13 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum Constants {
|
@objcMembers
|
||||||
|
class Constants: NSObject {
|
||||||
|
|
||||||
static let toBeRemovedNotificationCategoryIdentifier = "TO_BE_REMOVED"
|
static let toBeRemovedNotificationCategoryIdentifier: String = "TO_BE_REMOVED"
|
||||||
static let callInviteNotificationCategoryIdentifier = "CALL_INVITE"
|
static let callInviteNotificationCategoryIdentifier: String = "CALL_INVITE"
|
||||||
|
|
||||||
|
/// Notification userInfo key to present a notification even if the app is on foreground. Value should be set as a Bool for this key.
|
||||||
|
static let userInfoKeyPresentNotificationAlways: String = "ALWAYS_PRESENT_NOTIFICATION"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,6 +269,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
case .success(let (roomState, eventSenderName)):
|
case .success(let (roomState, eventSenderName)):
|
||||||
var notificationTitle: String?
|
var notificationTitle: String?
|
||||||
var notificationBody: String?
|
var notificationBody: String?
|
||||||
|
var additionalUserInfo: [AnyHashable: Any]?
|
||||||
|
|
||||||
var threadIdentifier: String? = roomId
|
var threadIdentifier: String? = roomId
|
||||||
let currentUserId = account.mxCredentials.userId
|
let currentUserId = account.mxCredentials.userId
|
||||||
@@ -383,6 +384,8 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
// only send VoIP pushes if ringing is enabled for group calls
|
// only send VoIP pushes if ringing is enabled for group calls
|
||||||
if RiotSettings.shared.enableRingingForGroupCalls {
|
if RiotSettings.shared.enableRingingForGroupCalls {
|
||||||
self.sendVoipPush(forEvent: event)
|
self.sendVoipPush(forEvent: event)
|
||||||
|
} else {
|
||||||
|
additionalUserInfo = [Constants.userInfoKeyPresentNotificationAlways: true]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,7 +411,8 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
threadIdentifier: threadIdentifier,
|
threadIdentifier: threadIdentifier,
|
||||||
userId: currentUserId,
|
userId: currentUserId,
|
||||||
event: event,
|
event: event,
|
||||||
pushRule: pushRule)
|
pushRule: pushRule,
|
||||||
|
additionalInfo: additionalUserInfo)
|
||||||
|
|
||||||
NSLog("[NotificationService] notificationContentForEvent: Calling onComplete.")
|
NSLog("[NotificationService] notificationContentForEvent: Calling onComplete.")
|
||||||
onComplete(notificationContent)
|
onComplete(notificationContent)
|
||||||
@@ -466,7 +470,8 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
threadIdentifier: String?,
|
threadIdentifier: String?,
|
||||||
userId: String?,
|
userId: String?,
|
||||||
event: MXEvent,
|
event: MXEvent,
|
||||||
pushRule: MXPushRule?) -> UNNotificationContent {
|
pushRule: MXPushRule?,
|
||||||
|
additionalInfo: [AnyHashable: Any]? = nil) -> UNNotificationContent {
|
||||||
let notificationContent = UNMutableNotificationContent()
|
let notificationContent = UNMutableNotificationContent()
|
||||||
|
|
||||||
if let title = title {
|
if let title = title {
|
||||||
@@ -484,12 +489,16 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
if let soundName = notificationSoundName(fromPushRule: pushRule) {
|
if let soundName = notificationSoundName(fromPushRule: pushRule) {
|
||||||
notificationContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: soundName))
|
notificationContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: soundName))
|
||||||
}
|
}
|
||||||
notificationContent.userInfo = notificationUserInfo(forEvent: event, andUserId: userId)
|
notificationContent.userInfo = notificationUserInfo(forEvent: event,
|
||||||
|
andUserId: userId,
|
||||||
|
additionalInfo: additionalInfo)
|
||||||
|
|
||||||
return notificationContent
|
return notificationContent
|
||||||
}
|
}
|
||||||
|
|
||||||
private func notificationUserInfo(forEvent event: MXEvent, andUserId userId: String?) -> [AnyHashable: Any] {
|
private func notificationUserInfo(forEvent event: MXEvent,
|
||||||
|
andUserId userId: String?,
|
||||||
|
additionalInfo: [AnyHashable: Any]? = nil) -> [AnyHashable: Any] {
|
||||||
var notificationUserInfo: [AnyHashable: Any] = [
|
var notificationUserInfo: [AnyHashable: Any] = [
|
||||||
"type": "full",
|
"type": "full",
|
||||||
"room_id": event.roomId as Any,
|
"room_id": event.roomId as Any,
|
||||||
@@ -498,6 +507,11 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
if let userId = userId {
|
if let userId = userId {
|
||||||
notificationUserInfo["user_id"] = userId
|
notificationUserInfo["user_id"] = userId
|
||||||
}
|
}
|
||||||
|
if let additionalInfo = additionalInfo {
|
||||||
|
for (key, value) in additionalInfo {
|
||||||
|
notificationUserInfo[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
return notificationUserInfo
|
return notificationUserInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user