首页 > 解决方案 > 我们如何注册一个多平台应用程序以在 iOS 14 中接收通知?

问题描述

在 iOS 上,主应用程序如下:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

AppDelegate 不再属于 Multiplatform app 项目类型,我们如何注册应用以接收通知并注册移动设备?

我知道如何在 AppDelegate 中做到这一点,但是没有 AppDelegate,我不知道如何注册通知。

任何帮助将不胜感激!

标签: iosswiftuiapple-push-notificationsmultiplatformios14

解决方案


查看 UIApplicationDelegateAdaptor 和它的 NS* 等价物。它们让您提供一个将用作应用程序委托的类。示例:https ://www.hackingwithswift.com/quick-start/swiftui/what-is-the-uiapplicationdelegateadaptor-property-wrapper


推荐阅读