Skip to content

Instantly share code, notes, and snippets.

$ ssh -i "/path/to/your/PEM-KEY.pem" ubuntu@YOUR-INSTANCE-IP
$ sudo apt-get update
$ sudo apt-get install ruby
$ sudo apt-get install wget
$ cd /home/ubuntu
var messages : [String] = [] //(1)
override func viewDidLoad() {
...
messageListener() //(2)
}
func messageListener(){
Firestore.firestore().collection("messages")
.whereField("created", isGreaterThan: Date.timeIntervalBetween1970AndReferenceDate - 1000) //(3)
{
"created": 1539660445.5783448,
"message": "Hello, world!"
}
override func viewDidLoad() {
...
statusListener() //(1)
}
func statusListener(){
Firestore.firestore().collection("settings").document("device1") //(2)
.addSnapshotListener { documentSnapshot, error in
guard let document = documentSnapshot else { //(3)
print("Error fetching document: \(error!)")
@IBAction func onChangeSelection(_ sender: Any) {
let COLORS = ["ff0000","00ff00","0000ff"]
let selection = selectionSegment.selectedSegmentIndex
let color = COLORS[selection]
let ref = Firestore.firestore().collection("settings").document("device1")
ref.setData([
"status": selection,
"color": color
]){ err in
if let err = err {
var db: Firestore!
override func viewDidLoad() {
super.viewDidLoad()
Auth.auth().signInAnonymously(completion: nil)
let db = Firestore.firestore()
}
import Firebase
import FirebaseFirestore
$ pod install
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Firebase-Example' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Firebase-Example
pod 'Firebase/Core'
pod 'Firebase/Database'
$ pod init