IOS FCM push Notification-Static member 'instanceID' cannot be used on instance of type 'InstanceID'

I am trying to implement push notification as described in the documentation.

I am getting build error while updating the following method in xcode project:
#if USE_PUSH

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
InstanceID.instanceID().instanceID { (result, error) in
if let error = error {
NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), object: error)
} else if let result = result {
NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: result.token)
}
}
}

Getting build error like:
Static member ‘instanceID’ cannot be used on instance of type 'InstanceID’
I have updated pod file as mentioned in the documentation and installed it in xcode project.
I have seen in the web many people have faced i but nobody got any solution as of now.

check my answer on this github issue bug: Push Notification causing AppFlow Failure · Issue #4570 · ionic-team/capacitor · GitHub

Use this instead: 

  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Messaging.messaging().apnsToken = deviceToken
    Messaging.messaging().token { token, error in
      if let error = error {
        NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), object: error)
      } else if let token = token {
        NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: token)
      }
    }
  }

Thanks It has worked.
Capacitor team also updated their documentation as well.