Start
is a tool that handles different things occurring on app launch.
- Copy content of
Source
folder to your project.
or
- Use
Start
cocoapod
- iOS 9 and later
- Xcode 9 and later
- Swift 4
In your AppDelegate
, increment the number of launches stored by Start
library:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// ...
Start.launches.increment()
// ...
return true
}
Now you can retrieve number of app's launches:
let launchCount = Start.launches.count
It's very easy to check if the app is launched for the first time:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// ...
Start.launches.increment()
// ...
switch Start.launches.count {
case 1:
// The first launch
break
default:
// Not the first launch
break
}
// ...
return true
}
Sometimes you might need to reset the number of launches:
Start.launches.reset()
Start
is available under the Apache 2.0 license. See the LICENSE file for more info.