Skip to content

Commit

Permalink
[auth-swift] Remove FDL dep and update sample readme (#12864)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored May 1, 2024
1 parent 2cf218d commit 13d94d1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import FirebaseAuth
import FirebaseDynamicLinks
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
Expand Down Expand Up @@ -58,21 +57,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// MARK: - Firebase 🔥

private func handleIncomingDynamicLink(_ incomingURL: URL) {
DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL) { dynamicLink, error in
guard error == nil else {
return print("ⓧ Error in \(#function): \(error!.localizedDescription)")
}
let link = incomingURL.absoluteString

guard let link = dynamicLink?.url?.absoluteString else { return }
if AppManager.shared.auth().isSignIn(withEmailLink: link) {
// Save the link as it will be used in the next step to complete login
UserDefaults.standard.set(link, forKey: "Link")

if AppManager.shared.auth().isSignIn(withEmailLink: link) {
// Save the link as it will be used in the next step to complete login
UserDefaults.standard.set(link, forKey: "Link")

// Post a notification to the PasswordlessViewController to resume authentication
NotificationCenter.default
.post(Notification(name: Notification.Name("PasswordlessEmailNotificationSuccess")))
}
// Post a notification to the PasswordlessViewController to resume authentication
NotificationCenter.default
.post(Notification(name: Notification.Name("PasswordlessEmailNotificationSuccess")))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class PasswordlessViewController: OtherAuthViewController {

private func sendSignInLink(to email: String) {
let actionCodeSettings = ActionCodeSettings()
let stringURL = "https://\(authorizedDomain).firebaseapp.com/login?email=\(email)"

// Update "demo" to match the path defined in the dynamic link.
let stringURL = "https://\(authorizedDomain)/demo"
actionCodeSettings.url = URL(string: stringURL)
// The sign-in operation must be completed in the app.
actionCodeSettings.handleCodeInApp = true
Expand All @@ -47,6 +49,7 @@ class PasswordlessViewController: OtherAuthViewController {

// Set `email` property as it will be used to complete sign in after opening email link
self.email = email
print("successfully sent email")
}
}

Expand Down
3 changes: 0 additions & 3 deletions FirebaseAuth/Tests/SampleSwift/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ target 'AuthenticationExample' do

pod 'RecaptchaEnterprise', '~> 18.3'

### For Email Link/Passwordless Auth
pod 'FirebaseDynamicLinks', :path => '../../..'

## Pod for Sign in with Google
pod 'GoogleSignIn'

Expand Down
Loading

0 comments on commit 13d94d1

Please sign in to comment.