-
Peter J. Keleher authoredPeter J. Keleher authored
Assignment 5: Tok: Firebase and Playing Video
Due: May 17, 2020, 11:59:59 pm, v1.0
(live doc, be sure to check back frequently)
Goals
- learn to use external database, storage
- AVKit
Approach
In this project we are going to build a pared-down version of TikTok. You are going to build an app that allows you to upload URLs of online videos to a database, play those videos, and "like" your favorites.
We will be using the Firebase Realtime Database to store the URLs, "likes", and viewing information.
Quick demo available here
Steps
There are many steps to this project; I encourage you to start early.
Step 1: Set Up Your Database and Create Your App
In this step we are going to set up an iOS app and tie it into the database.
- Create a brand new app called
assign5
in your repository.- single-view
- no tests
- bundle id must be
edu.maryland.cmsc436.spring2020.openTok
, though we will possibly change this later.
- Go to http://firebase.google.com/ and
register for the free Spark Plan.
- Work through the this guide to setting up a project.
- Name your Firebase project
assign5
as well, create a realtime database, and do not forget to downloadGoogleService-Info.plist
- Your
Podfile
should consist of the following:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'assign5' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for assign5
pod 'Firebase/Database'
end
- You do not need to know much about
Cocoapods. Create the above
Podfile in your top
assign5
directory. Install Cocoapods on your machine if you don't already have it. Easiest is to usesudo gem install cocoapods
, but if you don't have root access look here under "Sudo-less Installation". Then typepod install
on the command line inside your topassign5
directory. From then on, always open assign5.xcworkspace instead of "assign5.xcodeproj".
Try out your database! Go to https://console.firebase.google.com, create the realtime database if you haven't already, and then click on 'Database' (this is the realtime database). Click on rules:
to set up the "test" rules, i.e. no authentication (Note that I spent many hours trying to set up authentication for the whole class, but eventually decided it was going be far more trouble that it is worth. For your own apps you should always use authentication. I recommend the FirebaseUI
).
Now go to the data tab. Real-time means that as you insert data from your app, it will magically appear in the browser window (see the demo for an example). Assuming you have correctly set up cocoapods, the GoogleService-Info.plist
, and your AppDelegate.swift
(see the guide above), you should be able to place the following in the viewDidLoad()
of your main view controller, run it, and watch the data appear in a browser window: