From c5b19f252188a01dd7b12090f4776420e3714000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 28 Nov 2013 15:33:06 +0100 Subject: iOS: Forward [UIApplicationDelegate handleOpenURL:] to QDesktopServices The user may use QDesktopServices::setUrlHandler() in combination with the appropriate Info.plist keys (CFBundleURLTypes, CFBundleURLSchemes) to react to URL requests from other applications. This is among other things useful for handling OAuth authentication from applications such as Dropbox. See: https://www.dropbox.com/developers/core/start/ios We protect against recursive URL opening, but an application may still redirect a request to open a URL by opening another URL, eg a website. Task-number: QTBUG-35201 Change-Id: I9f1d246206c5594b1b65bb11fa98c6bcdefc443e Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosapplicationdelegate.mm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/plugins/platforms/ios/qiosapplicationdelegate.mm') diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm index cf702c82af..9cf1047a6b 100644 --- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm +++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm @@ -41,9 +41,14 @@ #include "qiosapplicationdelegate.h" +#include "qiosintegration.h" +#include "qiosservices.h" #include "qiosviewcontroller.h" #include "qioswindow.h" +#include +#include + #include @implementation QIOSApplicationDelegate @@ -82,6 +87,21 @@ return YES; } +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation +{ + Q_UNUSED(application); + Q_UNUSED(sourceApplication); + Q_UNUSED(annotation); + + if (!QGuiApplication::instance()) + return NO; + + QIOSIntegration *iosIntegration = static_cast(QGuiApplicationPrivate::platformIntegration()); + QIOSServices *iosServices = static_cast(iosIntegration->services()); + + return iosServices->handleUrl(QUrl::fromNSURL(url)); +} + - (void)dealloc { [window release]; -- cgit v1.2.3