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?

2
  • Did you find the source of your problem and where you able to solve it? Commented Sep 27, 2018 at 8:33
  • 1
    @coder I was able to solve the same problem by using MessagingDelegate instead. Apparently it was renamed. Commented Oct 3, 2018 at 11:31

4 Answers 4

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

Sign up to request clarification or add additional context in comments.

3 Comments

I already have that import statement in my AppDelegate.m. I am importing Firebase, FirebaseMessaging, and UserNotifications.
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.
in my case i forgot to add @import UserNotifications;
2

I found this useful in the pod file:

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

Now all dependencies are found.

Comments

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

Comments

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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.