ios - 我们如何注册一个多平台应用程序以在 iOS 14 中接收通知?
问题描述
在 iOS 上,主应用程序如下:
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
AppDelegate 不再属于 Multiplatform app 项目类型,我们如何注册应用以接收通知并注册移动设备?
我知道如何在 AppDelegate 中做到这一点,但是没有 AppDelegate,我不知道如何注册通知。
任何帮助将不胜感激!
解决方案
查看 UIApplicationDelegateAdaptor 和它的 NS* 等价物。它们让您提供一个将用作应用程序委托的类。示例:https ://www.hackingwithswift.com/quick-start/swiftui/what-is-the-uiapplicationdelegateadaptor-property-wrapper
推荐阅读
- python - 每次有标点符号时将字符串拆分成句子,用标点符号?
- hyperledger-fabric - Hyperledger 中的去中心化程度
- python - Python 装饰器吐出无
- c++ - 为什么在分配给成员变量之前获得 unique_ptr 的返回是一个问题?
- corda - 运行 Corda 4.4 企业工具资源管理器时出现 java.io.NotSerializableException
- mysql - 从 2 个不同的数据库(MSSQL Server 和 MySQL)获取数据的最佳方式
- excel - 从数据集中查找百分位数并消除异常值
- java - InvalidModuleDescriptorException:在模块中找不到包 hellofx.org.openjfx
- python-3.x - python3:从标准输入读取并在 EOF 上退出
- flutter - mainAxisAlignment 无法将 iconButton 对齐到顶部