diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index adef69ff2..06b5a1bbf 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -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); diff --git a/Classes/Swift/SwiftUtil.swift b/Classes/Swift/SwiftUtil.swift index fe28f288c..a9adb2adc 100644 --- a/Classes/Swift/SwiftUtil.swift +++ b/Classes/Swift/SwiftUtil.swift @@ -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) } } diff --git a/Classes/Swift/Voip/Theme/VoipTexts.swift b/Classes/Swift/Voip/Theme/VoipTexts.swift index 99446b6f9..1058db916 100644 --- a/Classes/Swift/Voip/Theme/VoipTexts.swift +++ b/Classes/Swift/Voip/Theme/VoipTexts.swift @@ -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:"") + } diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 1fc2639d5..c007f19d7 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -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]; diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings index 25ff586b0..5e0146c8f 100644 Binary files a/Resources/fr.lproj/Localizable.strings and b/Resources/fr.lproj/Localizable.strings differ