File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
41
41
42
42
return true
43
43
}
44
+
45
+ func applicationWillTerminate( _ application: UIApplication ) {
46
+ // This method will be called when the app is forcefully terminated.
47
+ // End all ongoing calls in this method.
48
+ let callManager = CXCallManager . shared
49
+ let ongoingCalls = callManager. currentCalls. compactMap { SendBirdCall . getCall ( forUUID: $0. uuid) }
50
+
51
+ ongoingCalls. forEach { directCall in
52
+ // Sendbird Calls: End call
53
+ directCall. end ( )
54
+
55
+ // CallKit: Request End transaction
56
+ callManager. endCXCall ( directCall)
57
+
58
+ // CallKit: Report End if uuid is valid
59
+ if let uuid = directCall. callUUID {
60
+ callManager. endCall ( for: uuid, endedAt: Date ( ) , reason: . none)
61
+ }
62
+ }
63
+ // However, because iOS gives a limited time to perform remaining tasks,
64
+ // There might be some calls failed to be ended
65
+ // In this case, I recommend that you register local notification to notify the unterminated calls.
66
+ }
44
67
}
45
68
46
69
extension AppDelegate : PKPushRegistryDelegate {
You can’t perform that action at this time.
0 commit comments