FG
๐Ÿ”Œ APIs & SDKsGoogle

Google as an Auth provider doesn't work on iOS saved to homescreen

Freshabout 20 hours ago
Mar 14, 20260 views
Confidence Score91%
91%

Problem

[REQUIRED] Describe your environment Operating System version: iOS 10 Firebase SDK version: 4.1.3 Firebase Product: auth [REQUIRED] Describe the problem Steps to reproduce: 0. Save the app on the homescreen on iOS 1. make a redirect or popup login with google Auth provider 2. if redirect: - webview is not a "valid user agent" 3. if popup: - gets stuck in Safari about:blank, doesn't open the app again to pass on the token Relevant Code: [code block]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Implement Custom URL Scheme for Google Auth on iOS Homescreen App

Medium Risk

The issue arises because when the app is saved to the iOS homescreen, it runs in standalone mode, which does not support the standard webview user agent required for Google authentication. This leads to failures in both redirect and popup methods, as the webview is not recognized as a valid user agent, and popups do not return to the app correctly.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Define Custom URL Scheme

    Add a custom URL scheme to your iOS app to handle redirects from Google Auth. This allows the app to open back into the correct context after authentication.

    xml
    Add the following to your Info.plist:
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>yourapp</string>
        </array>
      </dict>
    </array>
  2. 2

    Modify Firebase Auth Configuration

    Update your Firebase authentication configuration to include the custom URL scheme. This ensures that the authentication process can redirect back to your app correctly.

    javascript
    firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL)
      .then(() => {
        // Your authentication logic here
      });
  3. 3

    Handle URL in App Delegate

    Implement the URL handling method in your AppDelegate to capture the redirect from Google Auth and complete the login process.

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

    Test Authentication Flow

    After implementing the above changes, test the authentication flow by saving the app to the homescreen and performing a Google login. Ensure that the app opens correctly after authentication.

  5. 5

    Monitor for Errors

    Log any errors encountered during the authentication process to identify if further adjustments are needed. Use Firebase Crashlytics or similar tools for monitoring.

    swift
    Crashlytics.crashlytics().log("Google Auth Error: \(error.localizedDescription)")

Validation

To confirm the fix worked, save the app to the homescreen, initiate Google authentication, and verify that the app successfully redirects back after login without errors. Check logs for any issues.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

firebasegooglesdkbugapi:-authpriority:-p2