Show a dialog to requet the user to grant the local network permission.

This is required for ICE to operate correctly.
If not granted, SDK 5.0.16 will automatically disable ICE.
This commit is contained in:
Simon Morlat 2021-09-02 15:08:18 +02:00
parent 09d0867807
commit 98ac45f92a
4 changed files with 43 additions and 2 deletions

View file

@ -186,6 +186,7 @@ typedef struct _LinphoneManagerSounds {
- (void)setupGSMInteraction;
- (BOOL)isCTCallCenterExist;
- (void) checkLocalNetworkPermission;
@property (readonly) BOOL isTesting;
@property(readonly, strong) FastAddressBook *fastAddressBook;

View file

@ -1774,6 +1774,44 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
[ChatConversationView markAsRead:room];
}
/*
* If ICE is enabled, check if local network permission is given and show an alert message.
* It is indeed required for ICE to operate correctly.
* If it is not the the case, liblinphone will automatically skip ICE during the call.
* The purpose of this function is only to show the alert message.
*/
- (void) checkLocalNetworkPermission{
NSString *alertSuppressionKey = @"LocalNetworkPermissionAlertSuppression";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
LinphoneProxyConfig *defaultCfg = linphone_core_get_default_proxy_config(LC);
if (!defaultCfg) return;
LinphoneNatPolicy *natPolicy = linphone_proxy_config_get_nat_policy(defaultCfg);
if (!natPolicy || !linphone_nat_policy_ice_enabled(natPolicy))
return;
if (linphone_core_local_permission_enabled(LC)) return;
if (![defaults boolForKey: alertSuppressionKey]) {
UIAlertController *noticeView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Local network usage", nil)
message:NSLocalizedString(@"Granting the local network permission is recommended to enhance the audio & video quality. You may enable it from iOS settings.", nil)
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
UIAlertAction* ignoreForeverAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Don't show this again.", nil)
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
[defaults setBool:TRUE forKey: alertSuppressionKey];
}];
[noticeView addAction:defaultAction];
[noticeView addAction:ignoreForeverAction];
[PhoneMainView.instance presentViewController:noticeView animated:YES completion:nil];
}
}
- (void)call:(const LinphoneAddress *)iaddr {
// First verify that network is available, abort otherwise.
if (!linphone_core_is_network_reachable(theLinphoneCore)) {
@ -1813,7 +1851,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
[PhoneMainView.instance presentViewController:errView animated:YES completion:nil];
return;
}
[self checkLocalNetworkPermission];
// For OutgoingCall, show CallOutgoingView
[CallManager.instance startCallWithAddr:iaddr isSas:FALSE];
}

View file

@ -5,7 +5,7 @@ source "https://github.com/CocoaPods/Specs.git"
def all_pods
if ENV['PODFILE_PATH'].nil?
pod 'linphone-sdk', '~> 5.0.0'
pod 'linphone-sdk', '~> 5.0.16'
else
pod 'linphone-sdk', :path => ENV['PODFILE_PATH'] # local sdk
end

View file

@ -110,6 +110,8 @@
<string>Add tranfered files to your library</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Share photos with your friends and customize avatars</string>
<key>NSLocalNetworkUsageDescription</key>
<string>Stream audio and video through the local network</string>
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.org.linphone.phone</key>