Here is a simple AppDelegate
that I have made:
import SwiftUI
class AppDelegate: UIResponder, UIApplicationDelegate {
private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
print("application")
// first launch
// this method is called only on first launch when app was closed / killed
return true
}
private func applicationWillEnterForeground(application: UIApplication) -> Bool{
print("applicationWillEnterForeground")
// app will enter in foreground
// this method is called on first launch when app was closed / killed and every time app is reopened or change status from background to foreground (ex. mobile call)
return true
}
private func applicationDidBecomeActive(application: UIApplication) -> Bool {
print("applicationDidBecomeActive")
// app becomes active
// this method is called on first launch when app was closed / killed and every time app is reopened or change status from background to foreground (ex. mobile call)
return true
}
}
@main
struct CouponDeckApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
AppContentView()
}
}
}
The AppDelegate
doesn't seem to be calling any of its functions, though. It should be running them at 3 places, but none are running. Why is this happening, and how do I fix it?