Ask user permission for smart address book

This commit is contained in:
Christophe Deschamps 2024-10-03 13:52:32 +02:00
parent 614a44d096
commit dd5bc2f5cf
5 changed files with 57 additions and 1 deletions

View file

@ -1452,8 +1452,18 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
linphone_core_cbs_set_conference_state_changed(cbs, linphone_iphone_conference_state_changed);
bool reEnableRls = false;
if (![LinphoneManager.instance lpConfigBoolForKey:@"use_rls_presence_requested"] && [LinphoneManager.instance lpConfigBoolForKey:@"use_rls_presence"]) {
[LinphoneManager.instance lpConfigSetBool:false forKey:@"use_rls_presence"];
reEnableRls = true;
}
theLinphoneCore = linphone_factory_create_shared_core_with_config(factory, _configDb, NULL, [kLinphoneMsgNotificationAppGroupId UTF8String], true);
if (bctbx_list_size(linphone_core_get_account_list(theLinphoneCore)) > 0 && reEnableRls) { // Do not request rls allowance for users who had it before.
[LinphoneManager.instance lpConfigSetBool:true forKey:@"use_rls_presence"];
}
linphone_core_enable_auto_iterate(theLinphoneCore, true);
linphone_core_set_chat_messages_aggregation_enabled(theLinphoneCore, false);
linphone_core_add_callbacks(theLinphoneCore, cbs);

View file

@ -131,7 +131,42 @@ import linphonesw
} else {
Log.e("Invalid URL \(urlString)")
}
}
@objc static func requestRLSPresenceAllowance() {
let rls = UIAlertController(
title: VoipTexts.accept_rls_title,
message: VoipTexts.accept_rls,
preferredStyle: .actionSheet)
let accept = UIAlertAction(
title: VoipTexts.dialog_accept,
style: .default,
handler: { action in
Core.get().config?.setInt(section: "app", key: "use_rls_presence", value: 1)
Core.get().config?.setInt(section: "app", key: "use_rls_presence_requested", value: 1)
Core.get().friendListSubscriptionEnabled = true
})
let refuse = UIAlertAction(
title: VoipTexts.dialog_later,
style: .default,
handler: { action in
Core.get().config?.setInt(section: "app", key: "use_rls_presence", value: 0)
Core.get().config?.setInt(section: "app", key: "use_rls_presence_requested", value: 1)
Core.get().friendListSubscriptionEnabled = false
})
let pp = UIAlertAction(
title: VoipTexts.dialog_privacy_policy,
style: .default,
handler: { action in
openUrl(urlString: "https://www.linphone.org/privacy-policy")
})
rls.addAction(accept)
rls.addAction(pp)
rls.addAction(refuse)
rls.popoverPresentationController?.sourceView = PhoneMainView.instance().mainViewController.statusBarView
PhoneMainView.instance()?.present(rls, animated: true)
}
}

View file

@ -250,4 +250,11 @@ import UIKit
static let conference_info_confirm_removal_delete = NSLocalizedString("DELETE",comment:"")
static let conference_unable_to_share_via_calendar = NSLocalizedString("Unable to add event to calendar. Check permissions",comment:"")
static let screenshot_restrictions = NSLocalizedString("Can't take a screenshot due to app restrictions", comment: "")
@objc static let dialog_later = NSLocalizedString("Maybe later",comment:"")
@objc static let dialog_privacy_policy = NSLocalizedString("Privacy policy",comment:"")
@objc static let accept_rls_title = NSLocalizedString("Enable smart address book", comment:"")
@objc static let accept_rls = NSLocalizedString("To provide the best experience, your contacts phone numbers will be uploaded to our secure servers. We value your privacy, and this data will only be used as outlined in our privacy policy. You can disable this option any time in application settings",comment:"")
}

View file

@ -216,7 +216,11 @@
BOOL success = FALSE;
if(granted){
LOGD(@"CNContactStore authorization granted");
dispatch_async(dispatch_get_main_queue(), ^{
if (bctbx_list_size(linphone_core_get_account_list(LC)) == 0 && ![LinphoneManager.instance lpConfigBoolForKey:@"use_rls_presence_requested"]) {
[SwiftUtil requestRLSPresenceAllowance];
}
});
NSError *contactError;
CNContactStore* store = [[CNContactStore alloc] init];
[store containersMatchingPredicate:[CNContainer predicateForContainersWithIdentifiers:@[ store.defaultContainerIdentifier]] error:&contactError];