mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
add CallKit supported filter for NSE
This commit is contained in:
parent
e664cb8235
commit
9542b0e0f9
|
@ -38,6 +38,20 @@ public class SSKPreferences: NSObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public static var isCallKitSupported() -> Bool {
|
||||||
|
let userLocale = NSLocale.current
|
||||||
|
|
||||||
|
guard let regionCode = userLocale.regionCode else { return false }
|
||||||
|
|
||||||
|
if regionCode.contains("CN") ||
|
||||||
|
regionCode.contains("CHN") {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
private static let hasSavedThreadKey = "hasSavedThread"
|
private static let hasSavedThreadKey = "hasSavedThread"
|
||||||
|
|
|
@ -203,7 +203,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleSuccessForIncomingCall(for callMessage: CallMessage, using transaction: YapDatabaseReadWriteTransaction) {
|
private func handleSuccessForIncomingCall(for callMessage: CallMessage, using transaction: YapDatabaseReadWriteTransaction) {
|
||||||
if #available(iOSApplicationExtension 14.5, *) {
|
if #available(iOSApplicationExtension 14.5, *), SSKPreferences.isCallKitSupported {
|
||||||
if let uuid = callMessage.uuid, let caller = callMessage.sender, let timestamp = callMessage.sentTimestamp {
|
if let uuid = callMessage.uuid, let caller = callMessage.sender, let timestamp = callMessage.sentTimestamp {
|
||||||
let payload: JSON = ["uuid": uuid, "caller": caller, "timestamp": timestamp]
|
let payload: JSON = ["uuid": uuid, "caller": caller, "timestamp": timestamp]
|
||||||
CXProvider.reportNewIncomingVoIPPushPayload(payload) { error in
|
CXProvider.reportNewIncomingVoIPPushPayload(payload) { error in
|
||||||
|
@ -239,8 +239,15 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
||||||
}
|
}
|
||||||
let identifier = self.request?.identifier ?? UUID().uuidString
|
let identifier = self.request?.identifier ?? UUID().uuidString
|
||||||
let request = UNNotificationRequest(identifier: identifier, content: notificationContent, trigger: nil)
|
let request = UNNotificationRequest(identifier: identifier, content: notificationContent, trigger: nil)
|
||||||
|
let semaphore = DispatchSemaphore(value: 0)
|
||||||
|
UNUserNotificationCenter.current().add(request) { error in
|
||||||
|
if let error = error {
|
||||||
|
SNLog("Failed to add notification request due to error:\(error)")
|
||||||
|
}
|
||||||
|
semaphore.signal()
|
||||||
|
}
|
||||||
|
semaphore.wait()
|
||||||
SNLog("Add remote notification request")
|
SNLog("Add remote notification request")
|
||||||
UNUserNotificationCenter.current().add(request)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleSuccess(for content: UNMutableNotificationContent) {
|
private func handleSuccess(for content: UNMutableNotificationContent) {
|
||||||
|
|
Loading…
Reference in a new issue