From 53fdbbb00d21f940d0af6c58343f1ef44c55a91e Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Thu, 12 Dec 2024 10:42:14 +1100 Subject: [PATCH] try to fix a callkit issue --- Session.xcodeproj/project.pbxproj | 4 ++++ .../Notifications/PushRegistrationManager.swift | 16 ++-------------- .../NotificationServiceExtension.swift | 6 ++++-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 1aae439d1..6a81ad97c 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -7819,6 +7819,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 508; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -7856,6 +7857,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; + MARKETING_VERSION = 2.8.4; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; @@ -7888,6 +7890,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 508; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -7925,6 +7928,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; + MARKETING_VERSION = 2.8.4; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; diff --git a/Session/Notifications/PushRegistrationManager.swift b/Session/Notifications/PushRegistrationManager.swift index 6919fc91c..fde9a15e0 100644 --- a/Session/Notifications/PushRegistrationManager.swift +++ b/Session/Notifications/PushRegistrationManager.swift @@ -289,13 +289,10 @@ public class PushRegistrationManager: NSObject, PKPushRegistryDelegate, PushRegi return } - // FIXME: Initialise the `PushRegistrationManager` with a dependencies instance - let dependencies: Dependencies = Dependencies() - dependencies.storage.resumeDatabaseAccess() LibSession.resumeNetworkAccess() - let maybeCall: SessionCall? = Storage.shared.write { db in + let maybeCall: SessionCall? = Storage.shared.read { [dependencies = self.dependencies] db in var call: SessionCall? = nil do { @@ -307,17 +304,8 @@ public class PushRegistrationManager: NSObject, PKPushRegistryDelegate, PushRegi using: dependencies ) - let thread: SessionThread = try SessionThread.upsert( - db, - id: caller, - variant: .contact, - values: .existingOrDefault, - calledFromConfig: nil, - using: dependencies - ) - let interaction: Interaction? = try Interaction - .filter(Interaction.Columns.threadId == thread.id) + .filter(Interaction.Columns.threadId == caller) .filter(Interaction.Columns.messageUuid == uuid) .fetchOne(db) diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index 39d31ebd0..02579d8ff 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -95,8 +95,10 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension } } - let isCallOngoing: Bool = (UserDefaults.sharedLokiProject?[.isCallOngoing]) - .defaulting(to: false) + let isCallOngoing: Bool = ( + (UserDefaults.sharedLokiProject?[.isCallOngoing]).defaulting(to: false) && + (UserDefaults.sharedLokiProject?[.lastCallPreOffer]) != nil + ) // HACK: It is important to use write synchronously here to avoid a race condition // where the completeSilenty() is called before the local notification request