FIRMessagingDelegate 的消息:didReceiveMessage:未实现 - Firebase 4.1.1 - Swift 3
FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented - Firebase 4.1.1 - Swift 3
我将 Firebase 从 v3
升级到 v4
,但我在接收消息时遇到了一些问题,我收到了这个警告:
[Firebase/Messaging][I-FCM002019] FIRMessaging received data-message, but FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented
我知道我应该实现这个方法:
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)
}
但我仍然收到警告,请问我还应该做些什么吗?
我发现了问题,就是我忘记了这一行
Messaging.messaging().delegate = self
在这个方法中:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {}
我将 Firebase 从 v3
升级到 v4
,但我在接收消息时遇到了一些问题,我收到了这个警告:
[Firebase/Messaging][I-FCM002019] FIRMessaging received data-message, but FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented
我知道我应该实现这个方法:
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)
}
但我仍然收到警告,请问我还应该做些什么吗?
我发现了问题,就是我忘记了这一行
Messaging.messaging().delegate = self
在这个方法中:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {}