Skip to content

Instantly share code, notes, and snippets.

@wata
Last active April 8, 2020 04:47
Show Gist options
  • Save wata/9836d0615bbf2264af10eff3b1a325b2 to your computer and use it in GitHub Desktop.
Save wata/9836d0615bbf2264af10eff3b1a325b2 to your computer and use it in GitHub Desktop.
@IBAction func didTapEmailButton(_ sender: Any) {
let authUI = FUIAuth.defaultAuthUI()!
authUI.delegate = self
let settings = ActionCodeSettings()
settings.url = Constants.URLs.login
settings.handleCodeInApp = true
settings.setIOSBundleID(Constants.AppInfo.bundleIdentifier)
authUI.providers = [
FUIEmailAuth(
authAuthUI: authUI,
signInMethod: EmailLinkAuthSignInMethod,
forceSameDevice: true,
allowNewEmailAccounts: true,
actionCodeSetting: settings
)
]
let provider = authUI.providers.first as! FUIEmailAuth
provider.signIn(withPresenting: self, email: nil)
}
/// For more information, see [FirebaseUI for iOS — Auth](https://github.com/firebase/FirebaseUI-iOS/blob/master/Auth/README.md)
static func handle(universalLink link: URL) -> Bool {
guard
let emailLinkString = link.queries["link"] as? String,
let emailLink = URL(string: emailLinkString)
else { return false }
return FUIAuth.defaultAuthUI()?.handleOpen(emailLink, sourceApplication: nil) ?? false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment