FIRMessagingDelegate 的消息:didReceiveMessage:未实现 - Firebase 4.1.1 - Swift 3
Posted
技术标签:
【中文标题】FIRMessagingDelegate 的消息:didReceiveMessage:未实现 - Firebase 4.1.1 - Swift 3【英文标题】:FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented - Firebase 4.1.1 - Swift 3 【发布时间】:2017-09-07 10:04:54 【问题描述】:我将 Firebase 从 v3
升级到 v4
,但我在接收消息时遇到了一些问题,并且收到了以下警告:
[Firebase/Messaging][I-FCM002019] FIRMessaging 收到数据消息,但 FIRMessagingDelegate 的消息:didReceiveMessage:未实现
我知道我应该实现这个方法:
public func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage)
print(remoteMessage.appData)
//let title = remoteMessage.appData[("data"): "title"]
var title = "New Request"
for value in remoteMessage.appData
if let value = value as? [AnyHashable:Any]
print(value)
let message = "okay"
print(message)
self.showAlertAppDelegate(title: title ,message:message ,buttonTitle:"ok",window:self.window!)
print(title, message)
但是我仍然有警告,所以我应该采取更多措施吗?
【问题讨论】:
【参考方案1】:我发现了问题,就是我忘记了这一行
Messaging.messaging().delegate = self
在这个方法中:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
【讨论】:
和函数 didFinishLaunchingWithOption 被公开以上是关于FIRMessagingDelegate 的消息:didReceiveMessage:未实现 - Firebase 4.1.1 - Swift 3的主要内容,如果未能解决你的问题,请参考以下文章
使用未声明的类型“FIRMessagingDelegate”、“Messaging”和“FIRMessagingRemoteMessage”。