Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Firebase PhoneAuth in iOS #350

Open
onmyway133 opened this issue Aug 7, 2019 · 0 comments
Open

How to use Firebase PhoneAuth in iOS #350

onmyway133 opened this issue Aug 7, 2019 · 0 comments

Comments

@onmyway133
Copy link
Owner

onmyway133 commented Aug 7, 2019

Read Authenticate with Firebase on iOS using a Phone Number

Disable swizzling

Info.plist

<key>FirebaseAppDelegateProxyEnabled</key>
<string>NO</string>

Enable remote notification

Enable Capability -> Background mode -> Remote notification

AppDelegate.swift

import Firebase
import UIKit
import FirebaseAuth

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    private let appFlowController = AppFlowController()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        UIApplication.shared.registerForRemoteNotifications()
		FirebaseApp.configure()
        return true
    }

    // MARK: - Remote Notification

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Auth.auth().setAPNSToken(deviceToken, type: .unknown)
    }

    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        print(error)
    }

    func application(
        _ application: UIApplication,
        didReceiveRemoteNotification userInfo: [AnyHashable: Any],
        fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        completionHandler(.noData)
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
        if Auth.auth().canHandle(url) {
            return true
        } else {
            return false
        }
    }
}

Firebase push message looks like

▿ 1 element
  ▿ 0 : 2 elements
    ▿ key : AnyHashable("com.google.firebase.auth")
      - value : "com.google.firebase.auth"
    ▿ value : 1 element
      ▿ 0 : 2 elements
        - key : warning
        - value : This fake notification should be forwarded to Firebase Auth.

Captcha

To disable captcha during testing

Auth.auth().settings?.isAppVerificationDisabledForTesting = true
@onmyway133 onmyway133 changed the title How to use Firebase PhoneAuth How to use Firebase PhoneAuth in iOS Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant