简体   繁体   中英

iOS applicationDidBecomeActive: not called after didfinishlaunchingwithoptions: called

It is wired that logs for these two method are not always pairing.

# AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSLog(@"didFinishLaunchingWithOptions");
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    NSLog(@"applicationDidBecomeActive");
}

If your app is working with background fetch enable, iOS will launch your app as background fetch mode and prepare for data, un-periodically.

Launch due to a background fetch event, didFinishLaunchingWithOptions will called but applicationDidBecomeActive will not get called.

You can duplicate this scenario by turning on option "Launch due to a background fetch event" by edit run scheme in Xcode.

- (void)applicationDidBecomeActive:(UIApplication *)application

Is only called when your app is moved from inactive to active state or transitioned to foreground.

So not weird or wrong, everything is as it should be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM