DOWNLOAD RESOURCES:

Most apps nowadays have a backend so that we can authenticate users (sign up and log in), save user’s information, post and store data, retrieve and share data either it’s a video, photo or even secured information.

How can we do that? In this training, I’d love to share with you how to build a simple version of Twitter in iOS with Firebase.

You’ll learn:
+ How to use Firebase to authenticate users
+ Post data to Firebase
+ Structure data model using MVC
+ How to install Firebase using Cocoapods

DOWNLOAD RESOURCES:

*********
ABOUT CODE MASTERY
*********
Code Mastery is hosted by Duc Tran, founder of Developers Academy.

This is his free-style no notes, no teleprompter presentation and live coding broadcast with you guys everyday.

To join Duc’s free courses, register for free at

*********
MEET DUC TRAN
*********

Duc Tran is founder of Developers Academy, one of the world’s leading iOS, Android and Web development trainers.

More than 2,000,000 developers have studied his video trainings; 100,000 developers see his posts each month. Each year, Duc has helped 20,000 plus developers graduate from his online courses or video series.

*********
FREE TRAININGS IN IOS DEVELOPMENT
*********
To subscribe and get free tutorials, courses and weekly content, visit me at:
Connect with Duc on facebook:
Tweet him:
Get daily inspiration:

*********
SOURCE CODE IN THIS COURSE
*********

SET UP FIREBASE in AppDelegate.swift

import Firebase
FirebaseApp.configure()

import Foundation
import Firebase

class Story
{
var text: String = “”
var numberOfLikes = 0
var numberOfAngry = 0
let ref: DatabaseReference!

init(text: String) {
self.text = text
ref = Database.database().reference().child(“stories”).childByAutoId()
}

init(snapshot: DataSnapshot)
{
ref = snapshot.ref
if let value = snapshot.value as? [String : Any] {
text = value[“text”] as! String
numberOfLikes = value[“numberOfLikes”] as! Int
numberOfAngry = value[“numberOfAngry”] as! Int
}
}

func save() {
ref.setValue(toDictionary())
}

func toDictionary() – [String : Any]
{
return [
“text” : text,
“numberOfLikes” : numberOfLikes,
“numberOfAngry” : numberOfAngry
]
}
}

// Like and Dislike

extension Story {
func like() {
numberOfLikes += 1
ref.child(“numberOfLikes”).setValue(numberOfLikes)
}
}

DOWNLOAD DATA FROM FIREBASE

storiesRef.observe(.value, with: { (snapshot) in
self.stories.removeAll()

for child in snapshot.children {
let childSnapshot = child as! DataSnapshot
let story = Story(snapshot: childSnapshot)
print(story)
self.stories.insert(story, at: 0)
}

self.tableView.reloadData()
})

FULL SOURCE CODE AND VIDEO TRAINING: