diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-05-07 16:17:21 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-06-05 12:24:05 +0000 |
commit | a15db3a81aa6053d1b3ce346b4cb160c064a2c43 (patch) | |
tree | 69b6323b3d79207748ec3907dd9ff796818df92d /src/plugins/platforms/ios/qiosservices.mm | |
parent | 80583809041717f499c46aeb9b23f97562bcc9e5 (diff) |
iOS: Guard all uses of APIs not available in application extensions
Change-Id: Ic058a0c07f6cdd0a015f46db96fce1536a712711
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/qiosservices.mm')
-rw-r--r-- | src/plugins/platforms/ios/qiosservices.mm | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/plugins/platforms/ios/qiosservices.mm b/src/plugins/platforms/ios/qiosservices.mm index 3c44e1d7d6..7222bf6793 100644 --- a/src/plugins/platforms/ios/qiosservices.mm +++ b/src/plugins/platforms/ios/qiosservices.mm @@ -40,6 +40,9 @@ #include "qiosservices.h" #include <QtCore/qurl.h> +#include <QtCore/qdebug.h> +#include <QtCore/private/qcore_mac_p.h> + #include <QtGui/qdesktopservices.h> #import <UIKit/UIApplication.h> @@ -48,6 +51,11 @@ QT_BEGIN_NAMESPACE bool QIOSServices::openUrl(const QUrl &url) { + if (qt_apple_isApplicationExtension()) { + qWarning() << "openUrl not implement for application extensions yet"; + return false; + } + if (url == m_handlingUrl) return false; @@ -55,12 +63,25 @@ bool QIOSServices::openUrl(const QUrl &url) return openDocument(url); NSURL *nsUrl = url.toNSURL(); - UIApplication *application = [UIApplication sharedApplication]; + UIApplication *application = qt_apple_sharedApplication(); if (![application canOpenURL:nsUrl]) return false; - [application openURL:nsUrl options:@{} completionHandler:nil]; + static SEL openUrlSelector = @selector(openURL:options:completionHandler:); + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: + [UIApplication instanceMethodSignatureForSelector:openUrlSelector]]; + invocation.target = application; + invocation.selector = openUrlSelector; + + static auto kEmptyDictionary = @{}; + // Indices 0 and 1 are self and _cmd + [invocation setArgument:&nsUrl atIndex:2]; + [invocation setArgument:&kEmptyDictionary atIndex:3]; + // Fourth argument is nil, so left unset + + [invocation invoke]; + return true; } |