FIREBASE iOS TUTORIAL – BUILD TWITTER USING FIREBASE

[ad_1]
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:


Posted

in

by

Tags:

Comments

3 responses to “FIREBASE iOS TUTORIAL – BUILD TWITTER USING FIREBASE”

  1. Duc Tran Avatar

    Hey guys! This is a killer one-hour long training. I hope you enjoy this! You can download all the resources, Xcode projects and video trainings on this page: https://ductran.co/p/39

  2. Hooda K Avatar

    Great video. Can you please show how to use rules in Firebase? You have used default value "0" for numberOfLikes, can there be a rule like setting a default value, etc..?

  3. MEET SHAH Avatar

    Hii duc thanks for the video but make all these videos you make for iOS in Android studio also.
    Pls bro you teach good!!!

Leave a Reply

Your email address will not be published. Required fields are marked *