Sujay U N
Sujay U N

Reputation: 5340

Swift AppDeligate does not conform to protocol 'MessagingDelegate'

Using Swift2.3 and Xcode 8
I upgraded Firebase to version 4

I followed all mentioned Changes in the new version https://firebase.google.com/docs/reference/ios/naming-migration-guide#changes_in_the_new_version

Stil I get one error saying

Type 'AppDelegate' does not conform to protocol 'MessagingDelegate'

I dono what this method is changed to or which new method I need to add. kindly help me

class Appdelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate
{
    func application(remoteMessage: MessagingRemoteMessage)
    {
        let remoteMsgVar = remoteMessage.appData
        print("remoteMessage : ", remoteMsgVar)
    }
}

Upvotes: 3

Views: 1438

Answers (1)

Jen Person
Jen Person

Reputation: 7546

In order to conform to the MessagingDelegate protocol, you must include the functions:

func messaging(messaging: Messaging, didRefreshRegistrationToken fcmToken: String)
{

}

/// This method is called on iOS 10 devices to handle data messages received via FCM through its
/// direct channel (not via APNS). For iOS 9 and below, the FCM data message is delivered via the
/// UIApplicationDelegate's -application:didReceiveRemoteNotification: method.
@available(iOS 10.0, *)
func messaging(messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage)
{
    let FcmRcdNfnNryVal = remoteMessage.appData
    print("iOS 10.0 FcmRcdRmtNfnMsg : ", FcmRcdNfnNryVal)

}

For future reference, Xcode 8 will show you which functions are required in the protocol under errors:

rom

For anyone using Xcode 9, you can add the protocol stubs right from the error message.

AppDelegate

Upvotes: 4

Related Questions