Skip to content

Commit

Permalink
fix: ios crash while close app
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Jul 17, 2023
1 parent 50f9a23 commit a25010e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ios/Classes/RTMCallManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,31 @@ class RTMCallManager: NSObject, AgoraRtmCallDelegate, FlutterStreamHandler {
var eventChannel: FlutterEventChannel?
var eventSink: FlutterEventSink?

var manager: AgoraRtmCallKit?
var client: AgoraRtmKit?
var remoteInvitations: [Int: AgoraRtmRemoteInvitation] = [:]
var localInvitations: [Int: AgoraRtmLocalInvitation] = [:]
var manager: AgoraRtmCallKit? {
get {
return client?.rtmCallKit
}
}

init(_ client: AgoraRtmKit, _ clientIndex: Int, _ messenger: FlutterBinaryMessenger) {
eventChannel = FlutterEventChannel(
name: "io.agora.rtm.client\(clientIndex).call_manager",
binaryMessenger: messenger
)
manager = client.getRtmCall()
self.client = client
super.init()
eventChannel?.setStreamHandler(self)
manager?.callDelegate = self
self.manager?.callDelegate = self
}

deinit {
remoteInvitations.removeAll()
localInvitations.removeAll()
eventChannel = nil
client = nil
}

private func sendEvent(eventName: String, params: [String: Any?]) {
Expand Down
1 change: 1 addition & 0 deletions ios/Classes/SwiftAgoraRtmPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class SwiftAgoraRtmPlugin: NSObject, FlutterPlugin {

public func detachFromEngine(for registrar: FlutterPluginRegistrar) {
methodChannel.setMethodCallHandler(nil)
clients.removeAll()
}

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
Expand Down

0 comments on commit a25010e

Please sign in to comment.