@@ -10,6 +10,7 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
1010 let callObserver = CXCallObserver ( )
1111
1212 final let defaultCallKitIcon = " callkit_icon "
13+ final let callLoggingEnabledKey = " TV_CALL_LOGGING_ENABLED "
1314 var callKitIcon : String ?
1415
1516 var _result : FlutterResult ?
@@ -61,6 +62,8 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
6162 configuration. maximumCallGroups = 1
6263 configuration. maximumCallsPerCallGroup = 1
6364 let defaultIcon = UserDefaults . standard. string ( forKey: defaultCallKitIcon) ?? defaultCallKitIcon
65+ let callLoggingEnabled = UserDefaults . standard. optionalBool ( forKey: callLoggingEnabledKey) ?? true
66+ configuration. includesCallsInRecents = callLoggingEnabled
6467
6568 clients = UserDefaults . standard. object ( forKey: kClientList) as? [ String : String ] ?? [ : ]
6669 callKitProvider = CXProvider ( configuration: configuration)
@@ -356,10 +359,27 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
356359 // update icon & persist
357360 result ( updateCallKitIcon ( icon: newIcon) )
358361 return
362+ } else if flutterCall. method == " enableCallLogging " {
363+ let value = arguments [ " enabled " ] as? Bool ?? true
364+
365+ result ( updateEnableCallLogging ( value) )
366+ return
359367 }
360368 result ( true )
361369 }
362370
371+ /// Set and persist call logging in app preferences
372+ /// - Parameter value: value, true if it should be enabled
373+ func updateEnableCallLogging( _ value: Bool ) -> Bool {
374+ // Updating callkit configuration
375+ let configuration = callKitProvider. configuration
376+ configuration. includesCallsInRecents = value
377+
378+ // Save and persist setting
379+ UserDefaults . standard. set ( value, forKey: callLoggingEnabledKey)
380+ return true ;
381+ }
382+
363383 /// Updates the CallkitProvider configuration with a new icon, and saves this change to future use.
364384 /// - Parameter icon: icon path / name
365385 /// - Returns: true if succesful
0 commit comments