title: Phone Contacts With Firebase User
body: <p>I am creating a Chat App with Firebase, I can fetch users from firebase database. What I want is that my user list must only show users whose contacts are saved in my phone, instead of showing all the contacts. 
  Iam not able to figure out how should i start. 
  below is the fetch user method</p>
  
  <pre><code>func fetchUser(){
      Database.database().reference().child("Users").observe(.childAdded, with: { (snapshot) in
  
          if let dictonary = snapshot.value as? [String: AnyObject]{
              let user = Users()
              user.id = snapshot.key
           user.setValuesForKeys(dictonary)
              print(user.phoneNumber!,user.userName!,user.UserId!)
  
  
              self.users.append(user)
  
              DispatchQueue.main.async {
                  self.tableView.reloadData()
              }
          }
  
  
      }, withCancel: nil)
  }
  </code></pre>
  
  <p>And below is the function get to  contacts from phone </p>
  
  <pre><code>private func fetchContacts() {
      print("Attempting to fetch contacts today..")
  
      let store = CNContactStore()
  
      store.requestAccess(for: .contacts) { (granted, err) in
          if let err = err {
              print("Failed to request access:", err)
              return
          }
          if granted {
              print("Access granted")
  
              let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey]
              let request = CNContactFetchRequest(keysToFetch: keys as [CNKeyDescriptor])
  
              do {
  
                  try store.enumerateContacts(with: request, usingBlock: { (contact, stopPointerIfYouWantToStopEnumerating) in
  
  
                      let ph = (contact.phoneNumbers[0].value ).value(forKey: "digits") as! String
                      self.contacts.append(Contact(givenName: contact.givenName, familyName: contact.familyName, phoneNumbers: ph))
  
                  })
  
              } catch let err {
                  print("Failed to enumerate contacts:", err)
              }
  
          } else {
              print("Access denied..")
          }
      }
  }
  </code></pre>
  
  <p>Now what shall I do so that my tableview will only show users whose contacts are saved?</p>