2016-11-22 21 views
7

Bu eğiticiyi kullanarak her zaman firebase'i dağıtırken derleriz: https://firebase.google.com/docs/cloud-messaging/ios/client Dağıtımım SDK'sı 9.0.Firebase - 'UNUserNotificationCenterDelegate?' Yazıp 'AppDelegate' türünde bir değer atanamıyor.

Hatalar alıyorum:

Bunu nasıl düzeltebilirim

?

'UNUserNotificationCenterDelegate?' Yazıp 'AppDelegate' türünde bir değer atanamaz.

1 senaryo - I (öğretici aşağıdaki) adım adım ne yaptı: pod 'Firebase/Core' pod 'Firebase/Mesajlaşma'
  • : Aşağıdaki ile
    • pod init İndirilen go - pod AppDelegate sınıfının

    2 senaryo üstünde
  • "ithal Firebase" yüklemek Bir github depo yoluyla ogle demo iOS istemci uygulaması (https://github.com/firebase/quickstart-ios altında "mesajlaşma" klasörü) uygulamalarını derlenmiş
    • ... iyi çalıştı. Firebase, UIKit, UserNotifications: Aşağıdaki ile
    • pod init
    • : pod 'Firebase/Mesajlaşma'
    • pod
    • ithal aşağıdaki yüklemek
    • aşağıdaki adımlara göre benim mevcut XCode projesine kendi mantığı compied AppDelegate içinde, FirebaseInstanceID, FirebaseMessaging

    Kodu: At t

    func application(_ application: UIApplication, 
            didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
         // [START register_for_notifications] 
         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 
         } else { 
          let settings: UIUserNotificationSettings = 
           UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) 
          application.registerUserNotificationSettings(settings) 
         } 
         application.registerForRemoteNotifications() 
         // [END register_for_notifications] 
         FIRApp.configure() 
         // Add observer for InstanceID token refresh callback. 
         NotificationCenter.default.addObserver(self, 
                   selector: #selector(self.tokenRefreshNotification), 
                   name: .firInstanceIDTokenRefresh, 
                   object: nil) 
         return true 
        } 
    
    +1

    sizin AppDelegate sınıfı "UNUserNotificationCenterDelegate" protokolünü uygulayan yaptı: o AppDelegate sonu sen

    bu örnek uygulamasından kaynak koduna bakın 2 uzantıları (UNUserNotificationCenterDelegate, FIRMessagingDelegate) eklemeniz gerekir? Aksi takdirde derleyici türle eşleşemez ve bu nedenle de hata verir. – Surely

    +0

    Garip olan şey, Google'ın ios istemci örneğinin yalnızca UIResponder, UIApplicationDelegate uygulamasını gerçekleştirmesidir ... UNUserNotificationCenterDelegate ve FIRMessagingDelegate ekledim. Şimdi, "AppDelegate" "FIRMessagingDelegate" ile onaylamadığını söylüyor. Bunun üzerinde araştırma yapacağım. Teşekkürler. – user3427013

    +1

    Anladım ... Örnekte 2 uzantı var ... lol Ama öğretici bununla ilgili bir şey yok. Neyse. – user3427013

    cevap

    İlgili konular