ios: dismiss sheets on IncomingCallView, send notification if reportNewIncomingVoIPPushPayload fails

This commit is contained in:
Evgeny Poberezkin
2023-03-16 16:59:05 +00:00
parent 809cc1f234
commit 6724de09c9
3 changed files with 13 additions and 12 deletions

View File

@@ -46,6 +46,7 @@ class CallController: NSObject, CXProviderDelegate, PKPushRegistryDelegate, Obse
}
func providerDidReset(_ provider: CXProvider) {
logger.debug("CallController.providerDidReset")
}
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
@@ -134,7 +135,7 @@ class CallController: NSObject, CXProviderDelegate, PKPushRegistryDelegate, Obse
@objc(pushRegistry:didUpdatePushCredentials:forType:)
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
logger.debug("CallController: didUpdate push credentials for type \(type.rawValue, privacy: .public)")
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {

View File

@@ -65,6 +65,7 @@ struct IncomingCallView: View {
.padding(.vertical, 12)
.frame(maxWidth: .infinity)
.background(Color(uiColor: .tertiarySystemGroupedBackground))
.onAppear { dismissAllSheets() }
}
private func callButton(_ text: LocalizedStringKey, _ image: String, _ color: Color, action: @escaping () -> Void) -> some View {

View File

@@ -244,18 +244,17 @@ func receivedMsgNtf(_ res: ChatResponse) async -> (String, UNMutableNotification
case let .callInvitation(invitation):
// Do not post it without CallKit support, iOS will stop launching the app without showing CallKit
if useCallKit() {
CXProvider.reportNewIncomingVoIPPushPayload([
"displayName": invitation.contact.displayName,
"contactId": invitation.contact.id,
"media": invitation.callType.media.rawValue
]) { error in
if let error = error {
logger.error("reportNewIncomingVoIPPushPayload error \(error.localizedDescription, privacy: .public)")
} else {
logger.debug("reportNewIncomingVoIPPushPayload success for \(invitation.contact.id)")
}
do {
try await CXProvider.reportNewIncomingVoIPPushPayload([
"displayName": invitation.contact.displayName,
"contactId": invitation.contact.id,
"media": invitation.callType.media.rawValue
])
logger.debug("reportNewIncomingVoIPPushPayload success for \(invitation.contact.id)")
return (invitation.contact.id, (UNNotificationContent().mutableCopy() as! UNMutableNotificationContent))
} catch let error {
logger.error("reportNewIncomingVoIPPushPayload error \(String(describing: error), privacy: .public)")
}
return (invitation.contact.id, (UNNotificationContent().mutableCopy() as! UNMutableNotificationContent))
}
return (invitation.contact.id, createCallInvitationNtf(invitation))
default: