Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    How to get didFinishLaunchingWithOptions called in IOS delegate?

    Mobile and Embedded
    3
    7
    5338
    Loading More Posts
    • 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
      xiejing last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • X
          xiejing last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • X
              xiejing last edited by

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

              1 Reply Last reply Reply Quote 0
              • Gianluca
                Gianluca last edited by

                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 Reply Quote 0
                • X
                  xiejing last edited by

                  I used the category extension, thanks!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post