0

I am new to iOS Development..I want to implement firebase impolite UI

This is my ViewController file

import UIKit
import Firebase
import FirebaseCore
import FirebaseAuth
import FirebaseUI
import FirebaseFirestore

class ViewController: UIViewController{
    //let authUI = FUIAuth.defaultAuthUI()
    //let authui = FirebaseApp.configure()

    override func viewDidLoad() {
        super.viewDidLoad()
         // FirebaseApp.configure()
        if FirebaseApp.app() == nil {
            FirebaseApp.configure()
        }
        print("came inside viewdialoadds")
       //  logiin()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
         print("came inside parttwoooooooooooo")
    }

    @IBAction func loginfunction(_: UIButton) {
         print("Tappeddddddddddddddddddddd")
          logiin()
    }

    func logiin() {
        print("login called")
        if FirebaseApp.app() == nil {
             print("login called firebase now confieeddd")
            FirebaseApp.configure()
        }
       // FirebaseApp.configure()
        print("login called firebase UI  confieeddd")
        let authUI = FUIAuth.defaultAuthUI()
        // You need to adopt a FUIAuthDelegate protocol to receive callback
        authUI?.delegate = self as? FUIAuthDelegate
       // authUI.delegate = self

        let providers: [FUIAuthProvider] = [
            FUIGoogleAuth(),
            FUIPhoneAuth(authUI:FUIAuth.defaultAuthUI()!),
            ]
        self.authUI.providers = providers

        func application(_ app: UIApplication, open url: URL,
                         options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
            let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String?
            if FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication) ?? false {
                return true
            }
            // other URL handling goes here.
            return false
        }

    }

I am getting compile time error I add screenshot below please check it out

enter image description here

AnyOne please specify what is wrong in my code....I found doc here https://firebase.google.com/docs/auth/ios/firebaseui?authuser=0

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
demo
  • 672
  • 3
  • 9
  • 34
  • https://github.com/firebase/FirebaseUI-iOS/issues/310 I got released answer here..,I tried something like that but not working – demo Sep 03 '18 at 11:42
  • 1
    Just remove `self.` – vadian Sep 03 '18 at 11:42
  • Where did you do "var authUI` in your class as a property? Nowhere, that's why you get that error. It's like writing `self.randomName = "Hello"` if you didn't put a `randomName` property, it won't work. So either add the property, or remove the `self`. – Larme Sep 03 '18 at 11:43
  • @Larme shall I do this `authUI?.providers = providers`..it given me suggestions – demo Sep 03 '18 at 11:47
  • 1
    change `self.authUI.providers = providers` to `authUI?.providers = providers` – Kamran Sep 03 '18 at 11:50
  • @Kamran Thanks bro... – demo Sep 03 '18 at 11:52
  • @Kamran can you tell me when should I use this symbols `!` and `?` – demo Sep 03 '18 at 11:53
  • when you are sure that object is not `nil` then you can use force unwrap `!` else `?` – Kamran Sep 03 '18 at 11:58
  • 1
    @demo You need to read about Optional and Unwrapping. That's really basic knowledge to have in Swift. https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html – Larme Sep 03 '18 at 12:11

1 Answers1

0

Try to remove self, you have local variable authUI in function.

  • after removing I am getting some suggestion like `Value of optional type 'FUIAuth?' not unwrapped; did you mean to use '!' or '?'?` what should I do now – demo Sep 03 '18 at 11:50
  • you could try this authUI?.providers or change your variable like this let authUI = FUIAuth.defaultAuthUI()! – Vladyslav Shmatok Sep 03 '18 at 12:02
  • Thank you..can you please tell this bro....where should I call this function application() and what should I need to pass param like application("param","param") please help me sir..I new to iOS.i am basically android developer – – demo Sep 03 '18 at 12:33
  • Almost all application functions are in AppDelegate.swift. My advise for you is to find samples of code for this theme or find documentation – Vladyslav Shmatok Sep 03 '18 at 12:44
  • i did not get any sample code for firebase inbuilt Ui bro...I done same thing in android...but I iOS I feel very hard...please give me some sample for firebase login using ios – demo Sep 03 '18 at 12:54
  • Bro I want to use prebuild UI check this link...I have doc but I do not how to implement https://firebase.google.com/docs/auth/ios/firebaseui?authuser=0 – demo Sep 03 '18 at 13:30