Cannot find protocol declaration 'FIRMessagingDelegate'
Asked Answered
L

4

7

I'm trying to add Firebase Messaging to my iOS app. I've followed the steps in the Firebase documentation, namely:

  • Uploaded the APNs Certificate
  • Imported Firebase and added [FIRApp configure]
  • Imported Firebase Messaging with @import FirebaseMessaging and added FIRMessagingDelegate

However at this point I get an error:

@interface AppDelegate () <UNUserNotificationCenterDelegate, FIRMessagingDelegate>      
// Cannot find protocol declaration for FIRMessagingDelegate

I've updated my pods (suggested by similar issues found on Stack Overflow), but still get the same error. To confirm, running pod update gives the following output:

 Using FirebaseMessaging (1.2.2)

Any suggestions?

Lorenzetti answered 19/2, 2017 at 23:42 Comment(2)
Did you find the source of your problem and where you able to solve it?Horned
@Horned I was able to solve the same problem by using MessagingDelegate instead. Apparently it was renamed.Foulmouthed
G
11

The issue seems to be that the FIRMessagingDelegate protocol is declared in the new FirebaseMessaging framework.

Simply add:

@import FirebaseMessaging;

See more at: https://firebase.google.com/docs/reference/ios/firebasemessaging/api/reference/Protocols/FIRMessagingDelegate

and the sample app AppDelegate.m here: https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExample/AppDelegate.m#L62-L85

Genip answered 20/2, 2017 at 1:26 Comment(3)
I already have that import statement in my AppDelegate.m. I am importing Firebase, FirebaseMessaging, and UserNotifications.Lorenzetti
Great, however it still can't find the declaration... I'd look into the podfile and the cocoapod gem. It might need to be updated with [sudo] gem install cocoapods. Then you should do a pod update and it should be fine.Genip
in my case i forgot to add @import UserNotifications;Morose
A
2

I found this useful in the pod file:

pod 'Firebase/Messaging'
to
pod 'Firebase/Messaging', '~> 4.0.0'

Now all dependencies are found.

Adoptive answered 10/5, 2018 at 0:19 Comment(0)
A
0

Because my search brought me here, going to share this here:

If you're on Swift and getting this error, the 'FIR' prefix was dropped across all names, so you'll just use 'MessagingDelegate' instead of 'FIRMessagingDelegate'

Source: https://firebase.google.com/docs/reference/swift/naming-migration-guide

Aubreyaubrie answered 1/11, 2018 at 3:25 Comment(0)
B
0

My app was originally written in Objective-C and converted to Swift; I think that was the case with the original poster because, like mine, it looks like the error occurs in the Swift Bridging Header (which Xcode generates).

I solved this by adding this line to my Objective-C Bridging Header (AppName-Bridging-Header.h):

#import <FirebaseMessaging/FirebaseMessaging.h>

Bremser answered 8/7, 2024 at 22:45 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.