This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var messages : [String] = [] //(1) | |
override func viewDidLoad() { | |
... | |
messageListener() //(2) | |
} | |
func messageListener(){ | |
Firestore.firestore().collection("messages") | |
.whereField("created", isGreaterThan: Date.timeIntervalBetween1970AndReferenceDate - 1000) //(3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"created": 1539660445.5783448, | |
"message": "Hello, world!" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db: Firestore! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
Auth.auth().signInAnonymously(completion: nil) | |
let db = Firestore.firestore() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Firebase | |
import FirebaseFirestore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pod install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pod init |