2017-06-10 22 views
1

私はSwiftのiOSアプリケーションでFirebaseの通知を使用していますが、最近Firebase Messagingを1.2.3から2に更新し、コードが左と右の中心を壊し始めました。私はほとんどの問題を修正しましたが、私はこの問題に悩まされています。タイプ 'NSNotification.Name?' 'firInstanceIDTokenRefresh'のメンバーはありません

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
    UIApplication.shared.statusBarStyle = .lightContent 
    ... 

    FirebaseApp.configure() 

    // [START add_token_refresh_observer] 
    // Add observer for InstanceID token refresh callback. 
    NotificationCenter.default.addObserver(self, 
              selector: #selector(self.tokenRefreshNotification), 
              name: .firInstanceIDTokenRefresh, 
              object: nil) 
    // [END add_token_refresh_observer] 

    return true 
} 

私は私のアプリを実行しようとすると、私は次のエラーを取得する:

Type 'NSNotification.Name?' has no member 'firInstanceIDTokenRefresh'

はfirInstanceIDTokenRefreshに名前が変更されました。ここ

は私に問題を引き起こしてAppDelegateのアプリケーション機能の私の一部であります何か?

答えて

12

この通知はデリゲートメソッドに置き換えられているようです。

Firebase Cloud Messagingドキュメントには、トークンの生成を監視する方法について言及している:

Monitor token generation

To be notified whenever the token is updated, supply a delegate conforming to the FIRMessagingDelegate protocol. The following example registers the delegate and adds the proper delegate method:

func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) { 
    print("Firebase registration token: \(fcmToken)") 
} 

ドキュメントは、通知がまだ使用可能であることを言及EDIT

、それは今Notification.Name.MessagingRegistrationTokenRefreshedと呼ばれています。

+1

ありがとうございました! – Amit

関連する問題