Skip to content

Commit

Permalink
[Fix]CallKit crash (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis committed Feb 28, 2025
1 parent 07fe1c9 commit 891efe5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
22 changes: 10 additions & 12 deletions Sources/StreamVideo/CallKit/CallKitPushNotificationAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,17 @@ open class CallKitPushNotificationAdapter: NSObject, PKPushRegistryDelegate, Obs
"Received VoIP push notification with cid:\(content.cid) callerId:\(content.callerId) callerName:\(content.localizedCallerName)."
)

Task { @MainActor [weak self] in
self?.callKitService.reportIncomingCall(
content.cid,
localizedCallerName: content.localizedCallerName,
callerId: content.callerId,
hasVideo: content.hasVideo,
completion: { error in
if let error {
log.error(error)
}
callKitService.reportIncomingCall(
content.cid,
localizedCallerName: content.localizedCallerName,
callerId: content.callerId,
hasVideo: content.hasVideo,
completion: { error in
if let error {
log.error(error)
}
)
}
}
)
}

/// Decodes push notification Payload to a type that the CallKit implementation can use.
Expand Down
6 changes: 2 additions & 4 deletions Sources/StreamVideo/CallKit/CallKitService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ open class CallKitService: NSObject, CXProviderDelegate, @unchecked Sendable {
/// - callerId: The caller's identifier.
/// - hasVideo: Indicator if call is video or audio.
/// - completion: A closure to be called upon completion.
@MainActor
open func reportIncomingCall(
_ cid: String,
localizedCallerName: String,
Expand Down Expand Up @@ -157,7 +156,7 @@ open class CallKitService: NSObject, CXProviderDelegate, @unchecked Sendable {
Task {
do {
if streamVideo.state.connection != .connected {
let result = await Task { @MainActor in
let result = await Task {
try await streamVideo.connect()
}.result

Expand All @@ -170,7 +169,7 @@ open class CallKitService: NSObject, CXProviderDelegate, @unchecked Sendable {
}

if streamVideo.state.ringingCall?.cId != callEntry.call.cId {
Task { @MainActor in
Task {
streamVideo.state.ringingCall = callEntry.call
}
}
Expand Down Expand Up @@ -576,7 +575,6 @@ open class CallKitService: NSObject, CXProviderDelegate, @unchecked Sendable {
return provider
}

@MainActor
private func buildCallUpdate(
cid: String,
localizedCallerName: String,
Expand Down

0 comments on commit 891efe5

Please sign in to comment.