【问题标题】:Is possible to get the current location with Firebase (iOS)? [duplicate]是否可以使用 Firebase (iOS) 获取当前位置? [复制]
【发布时间】:2016-11-20 02:56:04
【问题描述】:

我阅读了 GeoFire for Firebase 的所有文档和一些示例,但我不明白是否可以获取用户的当前位置...有可能吗?如果是,我怎样才能得到它?

【问题讨论】:

  • 您应该使用核心位置来获取用户的位置。然后,您使用 Firebase 在数据库中存储/搜索它。
  • 你的问题毫无意义。 Firebase 是一个云数据库系统。它没有也不应该有任何获取用户位置的工具。这就像使用冰棒来报税一样。您想使用位置管理器。

标签: ios xcode firebase firebase-realtime-database geofire


【解决方案1】:

Geofire 在 github 上有一个很好的自述文件...

使用 Swift 检索位置

geoFire.getLocationForKey("firebase-hq", withCallback: { (location, error) in
  if (error != nil) {
    println("An error occurred getting the location for \"firebase-hq\": \(error.localizedDescription)")
  } else if (location != nil) {
    println("Location for \"firebase-hq\" is [\(location.coordinate.latitude), \(location.coordinate.longitude)]")
  } else {
    println("GeoFire does not contain a location for \"firebase-hq\"")
  }
})

看看herehere

【讨论】:

  • 是的,我已经阅读了它们,但我的理解是无法获取当前位置,我错了吗?
  • 您无法使用 firebase 获取当前位置...您可以将其保存到数据库中并进行检索!要获取当前位置,请使用 CCLocationManager 之类的东西以及那些 iOS 东西...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多