I am trying to create my first app, unfortunately everyone remembers their first piece of code with a new language, and needless to say, it has been a hassle and a half. Right now, I am using a downloaded test file to feel out how things workout with implementing Firebase with swift. Currently, I don't much care about anything besides getting the App to log the email and pass when creating a user into the database.
I have double and triple checked the GoogleService-Info.plist to make sure the correct API key is there. I have downloaded the Google file numerous times after checking that the bundle ID and all other information is correct. The App loads and runs, lets me input an email and a password and as soon as I hit the button to register it throws the Invalid API error. This is what my podfile looks like
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'FirebaseTutorial' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for FirebaseTutorial
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
end
This is the function code for the Registration.
@IBAction func createAccountAction(_ sender: AnyObject) {
if emailTextField.text == "" {
let alertController = UIAlertController(title: "Error", message: "Please enter your email and password", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
present(alertController, animated: true, completion: nil)
} else {
FIRAuth.auth()?.createUser(withEmail: emailTextField.text!, password: passwordTextField.text!) { (user, error) in
if error == nil {
print("You have successfully signed up")
//Goes to the Setup page which lets the user take a photo for their profile picture and also chose a username
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
self.present(vc!, animated: true, completion: nil)
} else {
let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
}
}}
This is the code in the AppDelegate.swift
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
Let me know if there's anything else I can provide in order to get some help with this. I feel pretty desperate every google search and search on here led me to create an account and ask this question. Everyone has to start somewhere right?