1

我正在向我的应用程序添加 PushKit 通知,并偶然发现了上述错误。

我做了什么:

  1. 启用推送通知
  2. 在后台模式下启用远程通知
  3. 添加了链接框架 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'

我猜有些东西不见了,但找不到什么。谁能帮我?

ps 我正在使用 xcode 9 和 swift 4

4

2 回答 2

0

在 Bridging-Header.h 中导入了#import,现在它可以工作了。

于 2018-01-19T08:58:18.030 回答
0

在您的AppDelegate文件中,只需在顶部添加导入,如下所示:

import PushKit

无需在 Bridging-Header 中添加任何内容。

于 2018-08-21T10:38:52.913 回答