【发布时间】:2021-02-07 06:40:35
【问题描述】:
我正在尝试从didReceiveRemoteNotification 生成一个组合发布者
类似于下面这段代码:
NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)
我想使用 SwiftUI 生命周期,不想使用 @UIApplicationDelegateAdaptor 的 AppDelegate 方法
【问题讨论】:
-
没有。 NotificationCenter.default.publisher(for: UIApplication.didReceiveRemoteNotification) 抛出错误。 => 类型“UIApplication”没有成员“didReceiveRemoteNotification”
-
收到远程通知时没有发布通知。您需要实现应用委托方法并从那里发送给发布者。