Option to use device ring tone for callkit ring

This commit is contained in:
Christophe Deschamps 2021-11-29 18:55:01 +01:00
parent 608577034d
commit 615f8f612d
5 changed files with 41 additions and 18 deletions

View file

@ -51,7 +51,7 @@ import AVFoundation
@objc var backgroundContextCameraIsEnabled : Bool = false
fileprivate override init() {
providerDelegate = ProviderDelegate()
providerDelegate = ProviderDelegate.shared
callController = CXCallController()
}
@ -62,6 +62,7 @@ import AVFoundation
return theCallManager!
}
@objc func setCore(core: OpaquePointer) {
self.core = Core.getSwiftObject(cObject: core)
self.core?.addDelegate(delegate: self)

View file

@ -329,6 +329,8 @@
// call section
{
[self setBool:[lm lpConfigBoolForKey:@"use_device_ringtone"] forKey:@"use_device_ringtone"];
[self setBool:linphone_core_get_use_info_for_dtmf(LC) forKey:@"sipinfo_dtmf_preference"];
[self setBool:linphone_core_get_use_rfc2833_for_dtmf(LC) forKey:@"rfc_dtmf_preference"];
@ -783,6 +785,9 @@
// call section
linphone_core_set_use_rfc2833_for_dtmf(LC, [self boolForKey:@"rfc_dtmf_preference"]);
[lm lpConfigSetBool:[self boolForKey:@"use_device_ringtone"] forKey:@"use_device_ringtone"];
[ProviderDelegate resetSharedProviderConfiguration];
linphone_core_set_use_info_for_dtmf(LC, [self boolForKey:@"sipinfo_dtmf_preference"]);
linphone_core_set_inc_timeout(LC, [self integerForKey:@"incoming_call_timeout_preference"]);
linphone_core_set_in_call_timeout(LC, [self integerForKey:@"in_call_timeout_preference"]);

View file

@ -1384,8 +1384,8 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
theLinphoneCore = linphone_factory_create_shared_core_with_config(factory, _configDb, NULL, [kLinphoneMsgNotificationAppGroupId UTF8String], true);
linphone_core_add_callbacks(theLinphoneCore, cbs);
[CallManager.instance setCoreWithCore:theLinphoneCore];
[ConfigManager.instance setDbWithDb:_configDb];
[CallManager.instance setCoreWithCore:theLinphoneCore];
[LinphoneManager.instance startLinphoneCore];

View file

@ -53,7 +53,8 @@ import os
* A delegate to support callkit.
*/
class ProviderDelegate: NSObject {
private let provider: CXProvider
static var shared = ProviderDelegate()
let provider: CXProvider
var uuids: [String : UUID] = [:]
var callInfos: [UUID : CallInfo] = [:]
@ -63,21 +64,27 @@ class ProviderDelegate: NSObject {
provider.setDelegate(self, queue: nil)
}
static var providerConfiguration: CXProviderConfiguration = {
let providerConfiguration = CXProviderConfiguration(localizedName: Bundle.main.infoDictionary!["CFBundleName"] as! String)
providerConfiguration.ringtoneSound = "notes_of_the_optimistic.caf"
providerConfiguration.supportsVideo = true
providerConfiguration.iconTemplateImageData = UIImage(named: "callkit_logo")?.pngData()
providerConfiguration.supportedHandleTypes = [.generic, .phoneNumber, .emailAddress]
providerConfiguration.maximumCallsPerCallGroup = 10
providerConfiguration.maximumCallGroups = 10
//not show app's calls in tel's history
//providerConfiguration.includesCallsInRecents = YES;
return providerConfiguration
}()
static var providerConfiguration: CXProviderConfiguration {
get {
let providerConfiguration = CXProviderConfiguration(localizedName: Bundle.main.infoDictionary!["CFBundleName"] as! String)
providerConfiguration.ringtoneSound = ConfigManager.instance().lpConfigBoolForKey(key: "use_device_ringtone") ? nil : "notes_of_the_optimistic.caf"
providerConfiguration.supportsVideo = true
providerConfiguration.iconTemplateImageData = UIImage(named: "callkit_logo")?.pngData()
providerConfiguration.supportedHandleTypes = [.generic, .phoneNumber, .emailAddress]
providerConfiguration.maximumCallsPerCallGroup = 10
providerConfiguration.maximumCallGroups = 10
//not show app's calls in tel's history
//providerConfiguration.includesCallsInRecents = YES;
return providerConfiguration
}
}
@objc static func resetSharedProviderConfiguration() {
shared.provider.configuration = ProviderDelegate.providerConfiguration
}
func reportIncomingCall(call:Call?, uuid: UUID, handle: String, hasVideo: Bool, displayName:String) {
let update = CXCallUpdate()

View file

@ -4,6 +4,16 @@
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Use device ringtone</string>
<key>Key</key>
<string>use_device_ringtone</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>