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;
}
@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?
- I have a qt application for ios and try to get didFinishLaunchingWithOptions() called.
-
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 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. -
What SDK are these ?
-
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 - (BOOL)application:(UIApplication *)application openURL:(NSURL )url sourceApplication:(NSString) sourceApplication annotation:(id)annotation {