Fix external URL opening

This commit is contained in:
Christophe Deschamps 2024-10-03 11:50:42 +02:00
parent c605914d80
commit 614a44d096
4 changed files with 22 additions and 21 deletions

View file

@ -20,6 +20,7 @@
#import "PhoneMainView.h"
#import "LinphoneManager.h"
#import "LinphoneIOSVersion.h"
#import "linphoneapp-Swift.h"
@implementation AboutView
@ -79,29 +80,21 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onLinkTap:(id)sender {
UIGestureRecognizer *gest = sender;
NSString *url = ((UILabel *)gest.view).text;
if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) {
LOGE(@"Failed to open %@, invalid URL", url);
}
[SwiftUtil openUrlWithUrlString:url];
}
- (IBAction)onPolicyTap {
NSString *url = @"https://www.linphone.org/privacy-policy";
if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) {
LOGE(@"Failed to open %@, invalid URL", url);
}
[SwiftUtil openUrlWithUrlString:url];
}
- (IBAction)onLicenceTap {
NSString *url = @"https://www.gnu.org/licenses/gpl-3.0.html";
if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) {
LOGE(@"Failed to open %@, invalid URL", url);
}
[SwiftUtil openUrlWithUrlString:url];
}
- (IBAction)onTranslateTap {
NSString *url = @"https://weblate.linphone.org/projects/linphone-iphone";
if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) {
LOGE(@"Failed to open %@, invalid URL", url);
}
[SwiftUtil openUrlWithUrlString:url];
}
- (IBAction)onDialerBackClick:(id)sender {

View file

@ -29,6 +29,7 @@
#import "UITextField+DoneButton.h"
#import "LinphoneAppDelegate.h"
#import "SVProgressHUD.h"
#import "linphoneapp-Swift.h"
#ifdef DEBUG
#define PROVIDER_NAME "apns.dev"
@ -100,9 +101,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onContactTap {
NSString *url = @"https://www.linphone.org/contact";
if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) {
LOGE(@"[Assistant] Failed to open %@, invalid URL", url);
}
[SwiftUtil openUrlWithUrlString:url];
}
- (void)viewDidLoad {
@ -1928,9 +1927,7 @@ UIColor *previousColor = (UIColor*)[sender backgroundColor]; \
- (IBAction)onLinkTap:(id)sender {
NSString *url = @"https://subscribe.linphone.org";
if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) {
LOGE(@"[Assistant] Failed to open %@, invalid URL", url);
}
[SwiftUtil openUrlWithUrlString:url];
}
- (IBAction)onAcceptTermsClick:(id)sender {

View file

@ -149,8 +149,6 @@
- (IBAction)onSubscribeTap:(id)sender {
UIGestureRecognizer *gest = sender;
NSString *url = ((UILabel *)gest.view).text;
if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) {
LOGE(@"Failed to open %@, invalid URL", url);
}
[SwiftUtil openUrlWithUrlString:url];
}
@end

View file

@ -121,5 +121,18 @@ import linphonesw
return log.dir == .Incoming && [.Missed,.Aborted,.EarlyAborted].contains(log.status)
}
@objc static func openUrl(urlString:String) {
if let url = URL(string: urlString) {
UIApplication.shared.open(url, options: [:], completionHandler: { success in
if (!success) {
Log.e("Unable to open URL \(urlString)")
}
})
} else {
Log.e("Invalid URL \(urlString)")
}
}
}