Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

swift

firebase

when i update firebase pods get bellow error:

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

 //notification

    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 as? UNUserNotificationCenterDelegate
        // For iOS 10 data message (sent via FCM)
        Messaging.messaging().remoteMessageDelegate = self as? MessagingDelegate

    }

how i can fix this?

like image 597
felon Avatar asked May 27 '18 10:05

felon


1 Answers

if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
 UNUserNotificationCenter.current().delegate = self

 let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
  UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
} else {
  let settings: UIUserNotificationSettings =
 UIUserNotificationSettings(types: [.alert, .badge, .sound], 
categories: nil)
application.registerUserNotificationSettings(settings)
}

application.registerForRemoteNotifications()

https://github.com/firebase/quickstart-ios/blob/dc2cd2db6e82e5c475fa3f0efe75df8b54f04544/messaging/MessagingExampleSwift/AppDelegate.swift#L40-L55

like image 92
Habib Alejalil Avatar answered Sep 22 '22 11:09

Habib Alejalil