【发布时间】:2018-01-19 08:44:25
【问题描述】:
我正在向我的应用程序添加 PushKit 通知,并偶然发现了上述错误。
我做了什么:
- 启用推送通知
- 在后台模式下启用远程通知
- 添加了链接框架 PushKit.framework
我用 PKPushRegistryDelegate 扩展了我的 AppDelegate 并实现了 pushRegistry 方法:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate {
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, forType type: PKPushType) {
}
.
.
.
一切似乎都很好,但是当我构建时出现错误:
No type or protocol named PKPushRegistryDelegate
在这种情况下我也尝试了扩展,但我得到了一个不同的错误:
Cannot find protocol declaration for 'PKPushRegistryDelegate'
我猜测缺少某些东西,但找不到什么。谁能帮我?
附言我正在使用 xcode 9 和 swift 4
【问题讨论】:
-
您是否在文件中导入了 PushKit ?
-
我做到了。问题是缺少 Bridging-Header.h 中的导入。它现在可以工作了:)
标签: ios push-notification delegates swift-protocols pushkit