我正在尝试将Firebase Messaging添加到我的iOS应用中。我按照Firebase documentation中的步骤进行了操作,即:
[FIRApp configure]
@import FirebaseMessaging
并添加了FIRMessagingDelegate
但此时我收到错误:
@interface AppDelegate () <UNUserNotificationCenterDelegate, FIRMessagingDelegate>
// Cannot find protocol declaration for FIRMessagingDelegate
我已经更新了我的pod(由Stack Overflow上发现的类似问题提示),但仍然会出现相同的错误。要确认,运行pod update
会提供以下输出:
Using FirebaseMessaging (1.2.2)
有什么建议吗?
答案 0 :(得分:6)
问题似乎是FIRMessagingDelegate
协议在新的FirebaseMessaging
框架中声明。
只需添加:
@import FirebaseMessaging;
以及此处的示例应用AppDelegate.m
:
https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExample/AppDelegate.m#L62-L85
答案 1 :(得分:0)
我发现这在pod文件中很有用:
pod 'Firebase/Messaging'
to
pod 'Firebase/Messaging', '~> 4.0.0'
现在找到所有依赖项。
答案 2 :(得分:-1)
因为我的搜索将我带到了这里,所以要在这里分享:
如果您使用的是Swift,并且遇到此错误,则会在所有名称中删除“ FIR”前缀,因此您只需使用“ MessagingDelegate”而不是“ FIRMessagingDelegate”
来源:https://firebase.google.com/docs/reference/swift/naming-migration-guide