5

I'm getting error:

"Value of type FIRMessaging has no member 'remoteMessageDelegate'" on FIRMessaging.messaging().remoteMessageDelegate = self

I get this snippet code from FCM setup guide:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    if #available(iOS 10.0, *) {
        let authOptions : UNAuthorizationOptions = [.alert, .badge, .sound]
        UNUserNotificationCenter.current().requestAuthorization(
            options: authOptions,
            completionHandler: {_,_ in })

        // For iOS 10 display notification (sent via APNS)
        UNUserNotificationCenter.current().delegate = self
        // For iOS 10 data message (sent via FCM)
        FIRMessaging.messaging().remoteMessageDelegate = self //Get error on this line

    } else {
        let settings: UIUserNotificationSettings =
            UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()
    }
AL.
  • 36,815
  • 10
  • 142
  • 281
Nic Chong
  • 149
  • 1
  • 8

5 Answers5

5

I had the same problem. It seems that Google documentation is out to date, I took a look Cocoapods Firebase Messaging page and I solved updating the cocoapods repo doing inside the Terminal:

pod repo update

And then replacing the following lines in my Podfile:

pod 'Firebase/Core'
pod 'Firebase/Messaging'

With:

 pod 'Firebase', '~> 3.7'
 pod 'FirebaseMessaging', '~> 1.2'
 pod 'FirebaseAnalytics', '~> 3.3'

This will download FirebaseMessaging 1.2 instead of 1.1

andrew_b
  • 721
  • 5
  • 7
  • I've been troubleshooting an issue related to FIRMessagingDelegate for about 5 hours now where it wouldn't let me assign the delegate to the AppDelegate.swift file and what solved it was setting a specific version of the pod with pod 'FirebaseMessaging', '~> 1.2' Thank you a ton!! –  Dec 16 '16 at 00:52
2

Run in the console:

pod update
Wilson
  • 9,006
  • 3
  • 42
  • 46
1

You need to update your cocoapod version

try updating version of cocoapod to latest from terminal app

sudo gem update

After updating to latest cocoapod update your pods

pod update
Hit_Var
  • 104
  • 9
  • This worked for me! Be patient when executing pod update. Took more than 5 minutes for me. – rbs Apr 18 '17 at 11:20
0

If you dont want to update all pods you can just update those Firebase pods

As of CocoaPods 1.0, 'pod repo udpate' does not happen on 'pod install' by default

pod update 'Firebase/Core'
pod update 'Firebase/Database'
pod update 'Firebase/Auth'
pod update 'Firebase/Messaging'
Pang Ho Ming
  • 1,299
  • 10
  • 29
-1

So you need to remove lines from podfile:

pod 'Firebase/Core'
pod 'Firebase/Messaging'

Then install pod, add these lines again and install again. This solved it for me.

Bryan
  • 14,756
  • 10
  • 70
  • 125
MrDmitriy
  • 1
  • 1