I want to create a unique identifier associated with each launch of my iOS app. I'm thinking about doing something like:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
var uuid: String?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
return true
}
func applicationDidBecomeActive(_ application: UIApplication) {
self.uuid = UUID().uuidString
}
And then whenever I want to use it throughout my app I'd do:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let appDelegate = UIApplication.shared.delegate as! AppDelegate
AppDelegate.uuid
}
}
Is there a better place to put this session uuid other than the App Delegate?