Value of type 'Messaging' has no member 'token'

Viewed 1135

I have this method to access the token (FireBaseCloudMessasing) in my VC instead of storing it in the AppDelegate but I got this error : Value of type 'Messaging' has no member 'token'

func getFCM(){
        Messaging.messaging().token { token, error in
          if let error = error {
            print("Error fetching FCM registration token: (error)")
          } else if let token = token {
            print("FCM registration token: (token)")
            self.fcmRegTokenMessage.text  = "Remote FCM registration token: (token)"
          }
        }
    }
2 Answers

Try to update dependencies. If you use Cocopoads, update Firebase/Messaging pod to the latest version with

$ pod update Firebase/Messaging

or if you want to update all the pods use

$ pod update

Worked for me

Related