How to handle push notifications with new pure SwiftUI App Protocol

Hi, after searching the forums a while, I'm wondering, with all the UIApplicationDelegate all gone for the new pure cross platform SwiftUI app, how do we handle APNs notifications and VoIP notification?

Replies

Push notifications should be a critical part of app, does anyone know how to do this? many thanks.
You can use @UIApplicationDelegateAdaptor to provide an AppDelegate:

Code Block swift
class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        return true
    }
}
@main
struct SampleApp: App {
    @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }  
}