Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to get didFinishLaunchingWithOptions called in IOS delegate?
QtWS25 Last Chance

How to get didFinishLaunchingWithOptions called in IOS delegate?

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 3 Posters 5.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xiejing
    wrote on last edited by
    #1

    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;
      }
      @end
      @
    • 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?
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xiejing
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What SDK are these ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xiejing
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • GianlucaG Offline
              GianlucaG Offline
              Gianluca
              wrote on last edited by
              #6

              My solution was to use the fantastic category extension of objective-C.
              I used this technique for making a Facebook Qt Quick item. https://github.com/GMaxera/QtFacebook

              @
              @interface QIOSApplicationDelegate
              @end
              //! Add a category to QIOSApplicationDelegate
              @interface QIOSApplicationDelegate (QFacebookApplicationDelegate)
              @end
              //! 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];
                }
                @end
                @

              There is a bug open to solve in more general way this issues:
              https://bugreports.qt-project.org/browse/QTBUG-38184

              1 Reply Last reply
              0
              • X Offline
                X Offline
                xiejing
                wrote on last edited by
                #7

                I used the category extension, thanks!

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved