Skip to content

Commit 65b420b

Browse files
committed
Merge branch '256-platform-channel-messages-sent-on-non-platform-thread'
2 parents 95f653f + e284863 commit 65b420b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.2.1
22

33
* Fix: [iOS] Race condition ending call remotely and locally results in a "End Call Failed: The operation couldn’t be completed." error. [Issue #184](https://github.com/cybex-dev/twilio_voice/issues/184)
4+
* Fix: [iOS] Plugin messages sent via Event Sink throwing an error due to sending from background thread. [Issue #256](https://github.com/cybex-dev/twilio_voice/issues/256)
45

56
## 0.2.0+1
67

ios/Classes/SwiftTwilioVoicePlugin.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -990,23 +990,26 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
990990

991991
private func sendPhoneCallEvents(description: String, isError: Bool) {
992992
NSLog(description)
993-
guard let eventSink = eventSink else {
994-
return
995-
}
996993

997994
if isError
998995
{
999-
eventSink(FlutterError(code: "unavailable",
1000-
message: description,
1001-
details: nil))
996+
let err = FlutterError(code: "unavailable", message: description, details: nil);
997+
sendEvent(err)
1002998
}
1003999
else
10041000
{
1005-
eventSink(description)
1001+
sendEvent(description)
10061002
}
10071003
}
10081004

1009-
1005+
private func sendEvent(_ event: Any) {
1006+
guard let eventSink = eventSink else {
1007+
return
1008+
}
1009+
DispatchQueue.main.async {
1010+
eventSink(event)
1011+
}
1012+
}
10101013

10111014
public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
10121015
let userInfo = response.notification.request.content.userInfo

0 commit comments

Comments
 (0)