Important: Please read the Qt Code of Conduct -

How to get didFinishLaunchingWithOptions called in IOS delegate?

  • Hi!

    • I have a qt application for ios and try to get didFinishLaunchingWithOptions() called.
      I got it work by extending QIOSApplicationDelegate like the followings:

    #import ".../qtbase/src/plugins/platforms/ios/QIOSApplicationDelegate .h"
    @implementation QIOSApplicationDelegate

    • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      [application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
      return YES;
    • It really works but i have to import the absolute path of QIOSApplicationDelegate .h because i can't find the header file in qt include folder. It may cause compile failed on other computers and have to change my code if the path changed.
    • So is there a better way to call the didFinishLaunchingWithOptions in qt applications for ios?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    That file is part of the QPA and thus not publicly available. However for what you want to do, there's no real need to try to subclass that delegate, you can call it e.g. from main

  • This Qt application for ios using QQuickView and QML and develop in a complete Qt environment, so there is no at all.
    But some public SDKs(e.g. for analytics and sharing) which have to override didFinishLaunchingWithOptions
    and openURL in ios application delegate.

  • Lifetime Qt Champion

    What SDK are these ?

  • facebook sharing SDK uses (BOOL)application:(UIApplication *)application openURL and an analytics SDK called umeng uses

  • My solution was to use the fantastic category extension of objective-C.
    I used this technique for making a Facebook Qt Quick item.

    @interface QIOSApplicationDelegate
    //! Add a category to QIOSApplicationDelegate
    @interface QIOSApplicationDelegate (QFacebookApplicationDelegate)
    //! Now add method for handling the openURL from Facebook Login
    @implementation QIOSApplicationDelegate (QFacebookApplicationDelegate)

    • (BOOL)application:(UIApplication *)application openURL:(NSURL )url sourceApplication:(NSString) sourceApplication annotation:(id)annotation {
      #pragma unused(application)
      #pragma unused(sourceApplication)
      #pragma unused(annotation)
      return [[FBSession activeSession] handleOpenURL:url];

    There is a bug open to solve in more general way this issues:

  • I used the category extension, thanks!

Log in to reply