mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Add push gateway rest client
This commit is contained in:
parent
7f0794139a
commit
ab126993df
1 changed files with 19 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
import UserNotifications
|
||||
import MatrixKit
|
||||
import MatrixSDK
|
||||
|
||||
class NotificationService: UNNotificationServiceExtension {
|
||||
|
||||
|
@ -35,6 +36,11 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
return CommonConfiguration()
|
||||
}()
|
||||
static var isLoggerInitialized: Bool = false
|
||||
private lazy var pushGatewayRestClient: MXPushGatewayRestClient = {
|
||||
let url = URL(string: BuildSettings.serverConfigSygnalAPIUrlString)!
|
||||
return MXPushGatewayRestClient(pushGateway: url.host!, andOnUnrecognizedCertificateBlock: nil)
|
||||
}()
|
||||
private var pushNotificationManager: PushNotificationManager = .shared
|
||||
|
||||
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||
// Set static application settings
|
||||
|
@ -430,6 +436,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
|
||||
// call notifications should stand out from normal messages, so we don't stack them
|
||||
threadIdentifier = nil
|
||||
self.sendVoipPush(forEvent: event)
|
||||
case .roomMember:
|
||||
let roomDisplayName = room.summary.displayname
|
||||
|
||||
|
@ -543,6 +550,18 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
return "QUICK_REPLY"
|
||||
}
|
||||
|
||||
private func sendVoipPush(forEvent event: MXEvent) {
|
||||
guard let token = pushNotificationManager.pushToken else {
|
||||
return
|
||||
}
|
||||
|
||||
pushGatewayRestClient.notifyApp(withId: "", pushToken: token, eventId: event.eventId, roomId: event.roomId, eventType: event.wireType, success: { (rejected) in
|
||||
|
||||
}) { (error) in
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension MXRoom {
|
||||
|
|
Loading…
Reference in a new issue