Merge pull request #5200 from vector-im/langleyd/5199_fix_failed_first_call_in_closed_app

Fix voip calls after singout/signin
This commit is contained in:
David Langley 2021-11-26 16:27:27 +00:00 committed by GitHub
commit 034e253fb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 8 deletions

View file

@ -266,6 +266,15 @@ Matrix session observer used to detect new opened sessions.
- (void)configurePushKit
{
MXLogDebug(@"[PushNotificationService] configurePushKit")
NSData* token = [_pushRegistry pushTokenForType:PKPushTypeVoIP];
if (token) {
// If the token is available, store it. This can happen if you sign out and back in.
// i.e We are registered, but we have cleared it from the the store on logout and the
// _pushRegistry lives through signin/signout as PushNotificationService is a singleton
// on app delegate.
_pushNotificationStore.pushKitToken = token;
MXLogDebug(@"[PushNotificationService] configurePushKit: Restored pushKit token")
}
_pushRegistry.delegate = self;
_pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];

View file

@ -66,7 +66,7 @@ class NotificationService: UNNotificationServiceExtension {
}()
private var pushNotificationStore: PushNotificationStore = PushNotificationStore()
private let localAuthenticationService = LocalAuthenticationService(pinCodePreferences: .shared)
private static let backgroundServiceInitQueue = DispatchQueue(label: "io.element.NotificationService.backgroundServiceInitQueue")
// MARK: - Method Overrides
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
@ -169,14 +169,16 @@ class NotificationService: UNNotificationServiceExtension {
MXKAccountManager.shared()?.forceReloadAccounts()
self.userAccount = MXKAccountManager.shared()?.activeAccounts.first
if let userAccount = userAccount {
if NotificationService.backgroundSyncService?.credentials != userAccount.mxCredentials {
MXLog.debug("[NotificationService] setup: MXBackgroundSyncService init: BEFORE")
self.logMemory()
NotificationService.backgroundSyncService = MXBackgroundSyncService(withCredentials: userAccount.mxCredentials)
MXLog.debug("[NotificationService] setup: MXBackgroundSyncService init: AFTER")
self.logMemory()
Self.backgroundServiceInitQueue.sync {
if NotificationService.backgroundSyncService?.credentials != userAccount.mxCredentials {
MXLog.debug("[NotificationService] setup: MXBackgroundSyncService init: BEFORE")
self.logMemory()
NotificationService.backgroundSyncService = MXBackgroundSyncService(withCredentials: userAccount.mxCredentials)
MXLog.debug("[NotificationService] setup: MXBackgroundSyncService init: AFTER")
self.logMemory()
}
completion()
}
completion()
} else {
MXLog.debug("[NotificationService] setup: No active accounts")
fallbackToBestAttemptContent(forEventId: eventId)

1
changelog.d/5199.bugfix Normal file
View file

@ -0,0 +1 @@
Fix bug where VoIP calls would not connect reliably after signout/signin.