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
// Main App File. | |
import SwiftUI | |
import Firebase | |
@main | |
struct MediumArticleApp: App { | |
@StateObject var authViewModel = AuthViewModel() | |
init() { | |
FirebaseApp.app() | |
} |
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 | |
// MARK: - Create our class of type ObservableObject which will allow us to access @Published variables we will create later. | |
class AuthViewModel: ObservableObject { | |
// MARK: - We're going to create two private let's, remember that let's are constants and cannot be mutated. Private means that we can only access those lets here in this file and no where else. The auth variable allows us to access Firebase Authentication methods and such, the firestore will allow us to access the Firestore ones. | |
private let auth = Auth.auth() | |
private let firestore = Firestore.firestore() | |
// MARK: - This is our registration function which allows us to simultaneously create a user within the authentication system and a entry within our Firestore database which allows for saving additional information. |
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 SwiftUI | |
import Firebase | |
@main | |
struct MediumArticleApp: App { | |
init() { | |
FirebaseApp.configure() | |
} | |