ios - How to check phone numbers stored in the phone against the firebase database? -


i using firebase , swift. once user signed in firauth, , validate user's phone number complete country code such as: +18585555555

i store username, logindate , phonenumber firebase db , use phone key. format:

  "users" : {     "+18585555555" : {       "lastlogindate" : "2016.07.15 21:39:26 gmt+3",       "name" : "john",       "phone" : "+18585555555"     },     "+18585555556" : {       "lastlogindate" : "2016.07.15 15:46:16 gmt+3",       "name" : "jane",       "phone" : "+18585555556"     },     "+18585555557" : {       "lastlogindate" : "2016.07.15 16:13:46 gmt+3",       "name" : "richard",       "phone" : "+18585555557"     }   } } 

i contacts using contact store ios9 so:

private func allcontacts() -> [cncontact] {     let contactstore = appdelegate.getappdelegate().contactstore     let keystofetch = [         cncontactformatter.descriptorforrequiredkeysforstyle(.fullname),         cncontactphonenumberskey,         cncontactimagedataavailablekey,         cncontactthumbnailimagedatakey     ]      var allcontainers: [cncontainer] = []     {         allcontainers = try contactstore.containersmatchingpredicate(nil)     } catch {         dlog("error fetching containers")     }      var results: [cncontact] = []      container in allcontainers {         let fetchpredicate = cncontact.predicateforcontactsincontainerwithidentifier(container.identifier)          {             let containerresults = try contactstore.unifiedcontactsmatchingpredicate(fetchpredicate, keystofetch: keystofetch)             results.appendcontentsof(containerresults)         } catch {             dlog("error fetching results container")         }     }      return results } 

for simplicity step 1: assume phone contacts phone numbers stored database format.

now check if contacts on phone exist in database. database potentially have millions of users stored above, phone number being key.

do query each number in phone against db? if so, can give query example please? json database new me , can't figure out how query 1 one.

for step 2: digits stored in cncontact might have country code in beginning , might not have it. country code +1 or +anything. if phone has 8585555555 , db has +1858555555 how write query now?

any in right direction appreciated.

thanks in advance,


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -