1

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");
}
David X. Lau
  • 31
  • 1
  • 5
  • If you don't return `YES` from `application:didFinishLaunchingWithOptions:`, your app is killed before it becomes active. Add `return YES;` after the log statement. – Avi Feb 19 '16 at 12:34

3 Answers3

2

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.

David X. Lau
  • 31
  • 1
  • 5
0

if you are using SceneDelegate try to remove it from your project. In my case I had to:

  • remove UIApplicationSceneManifest from Plist.
  • add @property (strong, nonatomic) IBOutlet UIWindow *window in AppDelegate
  • And add this code in AppDelegate
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     // Override point for customization after application launch.     
    self.window.frame = [[UIScreen mainScreen] bounds];
    [self.window makeKeyAndVisible];

     return YES;
 }

If you have more doubts about how to remove scenedelegate, check this post: How to remove Scene Delegate from iOS Application?

starmarmor
  • 41
  • 3
-3
- (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.

EdFunke
  • 605
  • 5
  • 4