0
0
iOS Swiftmobile~10 mins

Why Firebase provides mobile backend services in iOS Swift - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Firebase module in Swift.

iOS Swift
import [1]
Drag options to blanks, or click blank then click option'
AFirebase
BUIKit
CFoundation
DSwiftUI
Attempts:
3 left
💡 Hint
Common Mistakes
Importing UIKit instead of Firebase
Forgetting to import Firebase
2fill in blank
medium

Complete the code to initialize Firebase in the AppDelegate's didFinishLaunchingWithOptions method.

iOS Swift
FirebaseApp.[1]()
Drag options to blanks, or click blank then click option'
Aconfigure
Bstart
Cinitialize
Dlaunch
Attempts:
3 left
💡 Hint
Common Mistakes
Using start() or initialize() instead of configure()
Not calling FirebaseApp.configure() at all
3fill in blank
hard

Fix the error in the code to save data to Firestore database.

iOS Swift
let db = Firestore.firestore()
db.collection("users").document("user1").setData([1])
Drag options to blanks, or click blank then click option'
A("name": "Alice", "age": 25)
B["name": "Alice", "age": 25]
C["name" => "Alice", "age" => 25]
D[name: "Alice", age: 25]
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets
Omitting quotes around keys
Using => instead of : for key-value pairs
4fill in blank
hard

Fill both blanks to read data from Firestore and print the user's name.

iOS Swift
let db = Firestore.firestore()
db.collection("users").document("user1").getDocument { (document, error) in
  if let document = document, document.exists {
    let data = document.[1]()
    print(data[[2]] as? String ?? "No name")
  }
}
Drag options to blanks, or click blank then click option'
Adata
BgetData
C"name"
DdocumentData
Attempts:
3 left
💡 Hint
Common Mistakes
Using getData() instead of data()
Not quoting the dictionary key
5fill in blank
hard

Fill all three blanks to authenticate a user with email and password using Firebase Auth.

iOS Swift
Auth.auth().[1](withEmail: [2], password: [3]) { authResult, error in
  if let error = error {
    print("Error: \(error.localizedDescription)")
  } else {
    print("User signed in")
  }
}
Drag options to blanks, or click blank then click option'
AsignIn
B"user@example.com"
C"password123"
DcreateUser
Attempts:
3 left
💡 Hint
Common Mistakes
Using createUser instead of signIn
Not passing email and password as strings