简体   繁体   English

iOS中的Firebase Cloud Messaging有问题吗?

[英]Issue with Firebase Cloud Messaging in iOS?

Well I started to integrate the firbase cloud messaging for iOS. 好吧,我开始集成适用于iOS的firbase云消息传递。 I read this article to implement FCM. 我阅读了这篇文章以实现FCM。

https://firebase.google.com/docs/cloud-messaging/ios/client https://firebase.google.com/docs/cloud-messaging/ios/client

I have been following this doc to implement FCM but somehow I am not able to access few methods & classes instance. 我一直在遵循该文档来实现FCM,但是以某种方式我无法访问一些方法和类实例。

Messaging.messaging().delegate = self //No such class Messaging

Could find the method in protocol as mentioned below 可以在协议中找到如下所述的方法

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
  print("Firebase registration token: \(fcmToken)")

  // TODO: If necessary send token to application server.
  // Note: This callback is fired at each app startup and whenever a new token is generated.
}

So please tell what here am I doing wrong. 所以,请告诉我我在做什么错。

Try This.For Swift 试试这个。对于Swift

extension AppDelegate : MessagingDelegate {
// START refresh_token
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
    print("Firebase registration token: \(fcmToken)")
    print("Received Remote Message: 1\nCheck Out:\n")

}
// END refresh_token
// START ios 10 data message
// Receive data messages on iOS 10+ directly from FCM (bypassing APNs) when the app is in the foreground.
// To enable direct data messages, you can set Messaging.messaging().shouldEstablishDirectChannel to true.
func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
    print("Received data message: \(remoteMessage.appData)")
    print("Received Remote Message: 2\nCheck Out:\n")
}




// Receive data message on iOS 10 devices while app is in the foreground.
func application(received remoteMessage: MessagingRemoteMessage) {
    print("Received Remote Message: 3\nCheck In:\n")
    debugPrint(remoteMessage.appData)
    print("Received Remote Message: 3\nCheck Out:\n")

 }
   // END ios 10 data message
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM