how to determine in applicationDidBecomeActive whether it is the initial iPhone app launch?

前端 未结 3 506
再見小時候
再見小時候 2021-02-08 18:15

how to determine in how to determine in UIApplicationDidBecomeActiveNotification whether it is the initial app launch?whether it is the initial app launch?

that is the i

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-08 18:51

    In your applicationDidFinishLaunching:withOptions: put this:

    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"alreadyLaunched"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    Then, in didBecomeActive:

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"alreadyLaunched"]) {
        // is NOT initial launch...
    } else {
        // is initial launch...
    }
    

提交回复
热议问题