firebase / FirebaseUI-iOS

iOS UI bindings for Firebase.
Apache License 2.0
1.51k stars 477 forks source link

Firebase Auth Display reCAPTCHA on Actual iOS devices except some devices #737

Closed sambo-visal closed 5 years ago

sambo-visal commented 5 years ago

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

When I tried to Sign In using Phone Auth by FirebaseUI on my device it doesn't require the reCAPTCHA to verify that you're are not robot.

But when I tried to test on some other devices after I input phone number and click on verify and then it display the reCAPTCHA to verify that you are not robot. After I done verification and then the screen seem like in blank and it doesn't callback. Even I tried to test on simulator it display the same result.

The reCAPTCHA should display on simulator only, right? Why does it happen on actual device???

Steps to reproduce:

  1. Before Login I have enabled background modes like (Remote Notifications, Background Fetch, Audio...) Also copied REVERSED_CLIENT_ID from GoogleService to URL CUSTOM SCHEMES on Xcode, and then downloaded the APN CERTIFICATE AND UPLOADED TO FIREBASE
  2. Login using phone number on actual device
  3. completion the reCAPTCHA verification
  4. Return page as blank not doing the next step

Observed Results:

Expected Results:

Relevant Code:

Code that relevance to firebase setup

fileprivate func firebaseConfig() {
        FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.min)
        FirebaseApp.configure()
        authUI = FUIAuth.defaultAuthUI()
        authUI?.delegate = self
        Messaging.messaging().delegate = self
    }

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
        print("========== Firebase registration token: \(fcmToken)")
        let dataDict:[String: String] = ["token": fcmToken]
        NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
        // TODO: If necessary send token to application server.
        // Note: This callback is fired at each app startup and whenever a new token is generated.
    }
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

        let token = deviceToken.hexString
        print("====== This is device token ",deviceToken)

        let firebaseAuth = Auth.auth()
        firebaseAuth.setAPNSToken(deviceToken, type: .unknown)
        InstanceID.instanceID().instanceID { (result, error) in
            if let error = error {
                NSLog("Error getting instance ID ", error.localizedDescription)
            } else if let result = result {
                Messaging.messaging().apnsToken = deviceToken
                UserDefaults.standard.setFCMToken(value: result.token)
            }
        }
        print("=============== Device token",deviceToken.description)
        if let uuid = UIDevice.current.identifierForVendor?.uuidString {
            print(uuid)
        }
        UserDefaults.standard.setValue(token, forKey: "ApplicationIdentifier")
        UserDefaults.standard.synchronize()

    }

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        let firebaseAuth = Auth.auth()
        if (firebaseAuth.canHandleNotification(userInfo)){
            print("User infor ",userInfo)
            return
        }
    }
morganchen12 commented 5 years ago

The captcha will show on device whenever the background notification delivery fails for whatever reason. Silent notification delivery isn't guaranteed, so seeing a captcha from time to time is normal. There's nothing wrong with your implementation.

sambo-visal commented 5 years ago

@morganchen12 Thanks for reply. I am not complaining about displaying the captcha. What I am wondering is that after the completion of verification captcha page only return blank.

Here is similar issue I found on stackoverflow

sambo-visal commented 5 years ago

Please reopen this issue if possible

morganchen12 commented 5 years ago

Have you tried the solution mentioned in the StackOverflow question you linked?

sambo-visal commented 5 years ago

My bad! It doesn't work because I run it on my teammate laptop and he confused to disable Push Notification capabilities.