2016-11-19 40 views
0

我閱讀了所有的文檔和GeoFire for Firebase的一些例子,但我不明白它是否有可能獲得用戶的當前位置......有可能嗎?如果是的話,我怎麼能得到它?可以通過Firebase(iOS)獲取當前位置嗎?

+0

您應該使用Core Location來獲取用戶的位置。然後,您使用Firebase在數據庫中存儲/搜索它。 –

+0

你的問題沒有意義。 Firebase是一個雲數據庫系統。它沒有,也不應該有任何獲得用戶位置的設施。這就像使用冰棍來提交稅款。你想使用位置管理器。 –

回答

0

Geofire具有在github上良好的自述......

檢索使用雨燕

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的位置!

+0

是的,我已經閱讀過他們,但我的理解是,無法獲取當前位置,我錯了嗎? –

+0

您無法使用Firebase獲取當前位置......您可以將其保存到數據庫中並將其恢復! 要獲取當前位置,請使用諸如「CCLocationManager」和iOS這些東西...... – Anfuca