WIP: notification for voip call
This commit is contained in:
parent
4db87992b2
commit
e530b50938
|
@ -96,7 +96,7 @@ public final class SessionCall: NSObject {
|
|||
}
|
||||
|
||||
func reportIncomingCallIfNeeded() {
|
||||
guard case .offer = mode else { return }
|
||||
guard case .answer(_) = mode else { return }
|
||||
AppEnvironment.shared.callManager.reportIncomingCall(self, callerName: contactName) { error in
|
||||
if let error = error {
|
||||
SNLog("[Calls] Failed to report incoming call to CallKit due to error: \(error)")
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
<string>audio</string>
|
||||
<string>fetch</string>
|
||||
<string>remote-notification</string>
|
||||
<string>voip</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>Launch Screen</string>
|
||||
|
|
|
@ -234,6 +234,12 @@ public enum PushRegistrationError: Error {
|
|||
|
||||
voipTokenResolver.fulfill(pushCredentials.token)
|
||||
}
|
||||
|
||||
public func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
|
||||
owsAssertDebug(CurrentAppContext().isMainApp)
|
||||
owsAssertDebug(type == .voIP)
|
||||
Vibration.shared.startVibration()
|
||||
}
|
||||
}
|
||||
|
||||
// We transmit pushToken data as hex encoded string to the server
|
||||
|
|
|
@ -2,6 +2,7 @@ import UserNotifications
|
|||
import BackgroundTasks
|
||||
import SessionMessagingKit
|
||||
import SignalUtilitiesKit
|
||||
import CallKit
|
||||
|
||||
public final class NotificationServiceExtension : UNNotificationServiceExtension {
|
||||
private var didPerformSetup = false
|
||||
|
@ -95,7 +96,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
|||
notificationContent.badge = 1
|
||||
notificationContent.title = "Session"
|
||||
notificationContent.body = "\(senderDisplayName) is calling..."
|
||||
return self.handleSuccessForIncomingCall(for: notificationContent)
|
||||
return self.handleSuccessForIncomingCall(for: notificationContent, callID: callMessage.uuid!)
|
||||
default: return self.completeSilenty()
|
||||
}
|
||||
if (senderPublicKey == userPublicKey) {
|
||||
|
@ -215,9 +216,18 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
|||
contentHandler!(.init())
|
||||
}
|
||||
|
||||
private func handleSuccessForIncomingCall(for content: UNMutableNotificationContent) {
|
||||
private func handleSuccessForIncomingCall(for content: UNMutableNotificationContent, callID: String) {
|
||||
// TODO: poll for the real offer, play incoming call ring
|
||||
contentHandler!(content)
|
||||
if #available(iOSApplicationExtension 14.5, *) {
|
||||
CXProvider.reportNewIncomingVoIPPushPayload(["uuid": callID]) { error in
|
||||
if let error = error {
|
||||
owsFailDebug("Failed to notify main app of call message: \(error)")
|
||||
} else {
|
||||
Logger.info("Successfully notified main app of call message.")
|
||||
}
|
||||
self.contentHandler!(content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleSuccess(for content: UNMutableNotificationContent) {
|
||||
|
|
Loading…
Reference in New Issue