The problem AFAIK, is the delegate is not set when the app is launched.
A real main looks like:
int main(int argc, char *argv[])
{
int retVal = UIApplicationMain(argc, argv, nil, @"HelloViewAppDelegate");}But our main()s instantiate a QApplication. Only after that do we set the app delegate, so the initial call to didFinishLaunchingWithOptions is lost to whatever default delegate Qt provides.Someone correct me if I am wrong, but I'm pretty sure that is it.
Sent: Monday, August 22, 2016 at 7:53 PM
From: "Nuno Santos" <[email protected]>
To: "Manoel Neto" <[email protected]>
Cc: "Jason H" <[email protected]>, [email protected]
Subject: Re: [Interest] Location when the App is Killed/Terminated/Suspended
From: "Nuno Santos" <[email protected]>
To: "Manoel Neto" <[email protected]>
Cc: "Jason H" <[email protected]>, [email protected]
Subject: Re: [Interest] Location when the App is Killed/Terminated/Suspended
I think didFinishLaunchingWithOptions will only get called when the app is first loaded.
Have you tried the following ones?
- (void)applicationWillResignActive:(UIApplication *)application;
- (void)applicationDidEnterBackground:(UIApplication *)application;
-(void)applicationWillTerminate:(UIApplication *)application;
Nuno
On 22 Aug 2016, at 23:19, Manoel Neto <[email protected]> wrote:Hi Jason, thanks for your reply. My problem is not how to build
AppDelegate (I did this and it is ok when the app is active or in
background.). The question is: how to call
didFinishLaunchingWithOptions "when the ap is Killed, suspended or
terminated." ? Apple says that if an app uses "The significant-change
location service", iOS will wake it up if there's a location update to
be delivered, even if the app is terminated. But i cant make it work
using QT.
Best R,
Manoel
On Mon, Aug 22, 2016 at 6:54 PM, Jason H <[email protected]> wrote:@implementation QtAppDelegate
+(QtAppDelegate *)sharedQtAppDelegate{
static dispatch_once_t pred;
static QtAppDelegate *shared = nil;
dispatch_once(&pred, ^{
shared = [[super alloc] init];
});
return shared;
}
...
void QtAppDelegateInitialize()
{
[[UIApplication sharedApplication] setDelegate:[QtAppDelegate sharedQtAppDelegate]];
}
// int main() {
#if defined(Q_OS_IOS)
QtAppDelegateInitialize();
#endif
Sent: Monday, August 22, 2016 at 4:47 PM
From: "Manoel Neto" <[email protected]>
To: [email protected]
Subject: [Interest] Location when the App is Killed/Terminated/Suspended
Hi ,
I'm building an APP using QT/QML for IOS / Android and need to use
location when the APP is Killed, suspended or terminated. For IOS i
did an Objective C implementation and used
startMonitoringSignificantLocationChanges method from
CLLocationManager class.
Briefly, I extended the QIOSApplicationDelegate to have access to the
didFinishLaunchingWithOptions method. There i check the option key "
UIApplicationLaunchOptionsLocationKey" and, if ok, start monitoring
Location using a LocationManager Delegate. The Background App Refresh
is enable for the Location updates to work in the background.
I folow an example code (in IOS) tha works great even when the app is
Killed, suspended or terminated. The only diference from my QT code
is that in QT i use QIOSApplicationDelegate instead of system delegate
in IOS. But in QT the didFinishLaunchingWithOptions is never called
when the ap is Killed, suspended or terminated.
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
.....
shareModel = [LocationManager sharedManager];
if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]) {
[shareModel startMonitoringLocation];
}
}
Any suggestion?
Best R,
Manoel
--
Manoel Carvalho Marques Neto
[email protected]
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest
--
Manoel Carvalho Marques Neto
[email protected]
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
