APIManager
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate
Data model that encapsulates recorded audio file information including file URL and display title.
-
The currently authenticated user object containing user credentials and data
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Notification to go back to
InitialViewController.Declaration
Swift
let initialNotification = Notification.Name("PresentInitialViewController") -
Notification to go to
DemoViewController.Declaration
Swift
let demoNotification = Notification.Name("PresentDemoViewController") -
Reference to the presenting view controller used for displaying alerts and authentication UI - Warning: Must be set before calling authentication methods that present UI
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Firebase Realtime Database reference for storing and retrieving user data
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Shared singleton instance of the API manager - Note: Access this property instead of creating new instances
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Creates a new user account with Firebase Authentication using email and password. This method uses the credentials stored in the
userproperty to create a new Firebase account. After successful account creation, it displays a notification prompting the user to sign in and posts a notification to transition back to the initial view controller. - Precondition: Theuserproperty must be set with validuid(email) andpw(password) values - Note: This method clears theuserproperty after the operation completes (success or failure) - Important: Account creation does not automatically sign in the userDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Signs in an existing user with Firebase Authentication using email and password. This method authenticates the user using the credentials stored in the
userproperty. Upon successful sign-in, it loads the user's data from Firebase, displays a success notification, and posts a notification to transition to the demo/main view controller. - Precondition: Theuserproperty must be set with validuid(email) andpw(password) values - Note: This method clears theuserproperty if authentication fails - SeeAlso:createUser()for account creationDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Authenticates a user using Facebook Login SDK and Firebase Authentication. This method initiates the Facebook login flow, requesting email permissions. Upon successful Facebook authentication, it creates Firebase credentials using the Facebook access token and signs the user into Firebase. The user's data is then loaded and a notification is posted to transition to the demo/main view controller. - Note: Requires Facebook Login SDK to be properly configured in Info.plist - Important: The app must be registered with Facebook and have a valid App ID - SeeAlso:
googleSignIn()for Google authenticationDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Initiates the Google Sign-In authentication flow. This method triggers the Google Sign-In process, which will present the Google authentication UI. The actual authentication handling is done in the delegate methods
sign(_:didSignInFor:withError:). - Note: Requires Google Sign-In SDK to be properly configured with a valid GoogleService-Info.plist - Important: Thevcproperty must be set to present the Google Sign-In UI - SeeAlso:sign(_:didSignInFor:withError:)for authentication completion handlingDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Dismisses the Google Sign-In view controller. This delegate method is called when Google Sign-In needs to dismiss its authentication UI, typically after the user has completed or cancelled the authentication flow. - Parameters: - signIn: The Google Sign-In instance - viewController: The view controller to dismiss - Note: This is a GIDSignInUIDelegate method
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Dismisses the Google Sign-In view controller. This delegate method is called when Google Sign-In needs to dismiss its authentication UI, typically after the user has completed or cancelled the authentication flow. - Parameters: - signIn: The Google Sign-In instance - viewController: The view controller to dismiss - Note: This is a GIDSignInUIDelegate method
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Dismisses the Google Sign-In view controller. This delegate method is called when Google Sign-In needs to dismiss its authentication UI, typically after the user has completed or cancelled the authentication flow. - Parameters: - signIn: The Google Sign-In instance - viewController: The view controller to dismiss - Note: This is a GIDSignInUIDelegate method
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Dismisses the Google Sign-In view controller. This delegate method is called when Google Sign-In needs to dismiss its authentication UI, typically after the user has completed or cancelled the authentication flow. - Parameters: - signIn: The Google Sign-In instance - viewController: The view controller to dismiss - Note: This is a GIDSignInUIDelegate method
Declaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Saves the current user's data to Firebase Realtime Database. This method persists the user's data array to Firebase using a hashed version of their email address as the database key. The data is stored as an NSArray in the Firebase database for later retrieval. - Precondition: The
userproperty must be set with valid data to save - Note: Uses the hash value of the user's email as the database node identifier - Important: Data is only saved if both user and data properties are non-nilDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Loads the current user's data from Firebase Realtime Database. This method retrieves the user's previously saved data from Firebase using the hashed email address as the database key. The data is loaded asynchronously and stored in the user object's data property. - Precondition: The
userproperty must be set to identify which data to load - Note: Uses a single value event observer to fetch data once - Important: The loaded data is cast to [Float] array formatDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Logs out the current user by clearing the user session. This method performs a simple logout by setting the user property to nil, effectively clearing the cached user data and credentials from memory. - Note: This does not sign out from Firebase Auth or social providers - Important: Consider calling Firebase's
Auth.auth().signOut()for complete logoutDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate -
Presents a UIAlertController with the specified title, message, and action button. This utility method displays feedback to the user through a standard iOS alert dialog. It's used throughout the authentication flow to show success messages, errors, and other important notifications to the user. - Parameters: - title: The title text displayed at the top of the alert - message: The descriptive message body of the alert - actionTitle: The text for the dismissal button (typically "Ok") - Important: Requires the
vcproperty to be set to a valid UIViewController - Note: The alert is presented with a single default action that dismisses the alertDeclaration
Swift
class APIManager: NSObject, GIDSignInDelegate, GIDSignInUIDelegate
View on GitHub
APIManager Class Reference