Progressive Web App (PWA) in standalone mode OAuth error - google-chrome

After I saved my PWA (Test App) built using Create React App to homescreen and launched the app in standalone mode on android using chrome and iOS using safari. Then in the app I initiate Firebase method signInWithPopup(GoogleProvider) the device asks me if I want to open the action with Test App or other browsers installed on device i.e chrome, firefox. If I select to open with my Test App the popup opens and I select the correct Google account.
Error: After the google account selection the popup closes without ever redirecting back to my Test App.
If I instead to open the Firebase method signInWithPopup(GoogleProvider) with chrome browser and not my Test App the popup opens for google account selection and after I select the google account the popup closes and redirects back to the Test App momentarily and then
Error: directs back to chrome tab where is asks for google account to select while showing a loading indicator, and just hangs there.
There are no console error or warnings that come up .
Note 1: The error of popup not closing and staying in loading also occurs if I add the App to homescreen on a Windows 10 x64 machine using Version 64.0.3259.0 (Official Build) canary (64-bit) and launch as a standalone window.
Note 2: The error also occurs for signInWithPopup(Facebookprovider) and signInWithPopup(Twitterprovider) Also If I uninstall app from Homescreen and launch purely in browser the signing in OAuth flow works fine.
Note 3: After further troubleshooting it seems the error more specifically occurs when user input is required in the OAuth popup.
i.e If for example if user has previously given the Test App permissions through Facebook, the flow works fine and the popup closes. Also if only a single google account is detected and it has previously given app OAuth permissions then the popup works as it should. But If multiple google accounts exists on device then the user has to input a selection of which account to sign in through --> this leads to the previously mentioned error again. And using Twitter OAuth the error occurs every-time because twitter popup requires user to select Authorize App every-time.
UPDATE: I believe this may have something to do with google chrome recent changes to OAuth from Webview.
GIf of the error on windows machine: notice the popup for twitter auth never closes, even after authorizing the app, same thing occurs for google and facebook OAuth.

Reading Google documentation:
https://firebase.google.com/docs/auth/web/google-signin
Authenticate with Firebase using the Google provider object. You can prompt your users to sign in with their Google Accounts either by opening a pop-up window or by redirecting to the sign-in page. The redirect method is preferred on mobile devices.
So you have 2 options:
firebase.auth().signInWithPopup(provider)
firebase.auth().signInWithRedirect(provider)
The second must be used when you are into a mobile device.
So the question is: How I detect when I running into a mobile device ?
Code must be something like:
if ( isInMobileDevice) {
firebase.auth().getRedirectResult().then(function(result) { .... }
}
else {
firebase.auth().signInWithPopup(provider).then(function(result) { .... }
}
Sorry, Im still searching the way to get the correct value (true/false) into "isInMobileDevice"

you can stablish in the manifest of the app "display:standalone" then detect the launch mode like this
function isRunningStandalone() {
return (window.matchMedia('(display-mode: standalone)').matches);
}
...
if (isRunningStandalone()) {
/* This code will be executed if app is running standalone */
}

Good news, fixed in Chrome Canary
https://bugs.chromium.org/p/chromium/issues/detail?id=771418#c84

Related

Blazor WASM PWA: Google Chrome does not show Push Notifications

I've just tested Blazor example Blazing Pizza that uses push notifications as a PWA feature on Blazor. I changed public/private keys with my own generated ones and ran the project with MS Edge browser and push notifications worked as desired. But when I open it with Google Chrome, it doesn't shows any notification! (I allowed to show notifications).
I traced service-worker.js and found that notification hits the breakpoint, it means notification receives by browser but not showing:
I checked my Chrome's settings but not found anything to change.
I've found my mistake: I had blocked Google Chrome notifications in my Windows 10 notification settings!

Google OAuth UWP App - Close Browser Tab

Using this example here works well for me to add Google authentication to my UWP app (more specifically, to my UWP project in a Xamarin Forms app). However, after authenticating and automatically going back to the app via the redirect URL, the browser tab that was opened for the google log-in remains opened (it gets navigated to google.com and doesn't close after switching back to the app). Anyone know how to close it (just that tab, of course) automatically?

Pwa / Web app "restarts" after Google login

We have a project built in react thats using service worker and manifest for Pwa functions. We use google and facebook to login to the app.
Problem: When running it in Chrome browser (not fullframe) and login to the with eg. google its no problem. When i save it to homescreen and use it in standalone mode (pwa) and hit the our login btn ,google login window opens and i pic an account to login whith. After that the pwa restarts with the splashscreen and im back to where im started Not logged in. Please help
As discussed in this documentation,
When you launch your web app from the home screen a number of things happen behind the scenes:
Chrome launches.
The renderer that displays the page starts up.
Your site loads from the network (or from cache if it has a service
worker).
If you haven't done so, you may want to check Introduction to Service Worker for more information.
With this, you may want to try let the user automatically sign back in to avoid this logging redirect problem.
Additional code reference, see this SO post.

Handling Pop-ups in a Google Chrome Kiosk App

Has anyone successfully created a Google Chrome Kiosk App that can handle pop-ups?
My issue: We're trying to use Chromebits for public access catalogs at a public library. Locking down the kiosk app by domain works perfectly to ensure the Chromebits are only used with the catalog. However, an area of our catalog allows users to view their accounts. The account "edit" section is a pop-up, and the kiosk app will not allow it. Any workaround for this? Any other ideas?
I'm using "Kiosk" from the chrome app store.

Assign tray icon to Google Chrome web application

I need to create a web application which will be stored in the traybar of Windows, this to prevent users from accidentally close my application (without the need of a pre-close alert message).
I thought that Google Chrome's background apps could be the right way to go, mostly because I don't need cross-browser compatibility and I have to choose which browser my users will use to run this web application.
The only problem is that I don't understand if I can achieve what I need with this feature.
I've found only this example of background app in Chrome countdown app
But this app uses the "background page" feature, that is different from what I'm looking for.
How can I let a Chrome app be minimized in the traybar (or even in the taskbar would be ok) instead of be closed?
Try to use node-webkit (chromium + node.js) for it: https://github.com/rogerwang/node-webkit
It allow to create any web-app and it support tray icons: https://github.com/rogerwang/node-webkit/wiki/Tray
You can download my windows example app here: https://mega.co.nz/#!xQMzgbxD!S58G-V23QLNRDFC10xso41-T2V8OZQVsQEH-lr46R3s
If you want exactly chrome, try this NPAPI plugin example: http://minimizetotray.googlecode.com/files/SourceCode.zip from http://habrahabr.ru/post/73003/
Unfortunately, I don't think you will be able to achieve exactly what you're after. You might be able to combine the two solutions below to nearly achieve your requirements. However, I don't think the type of control you are after is available via Google Apps.
Google App Launcher
The Google App Launcher would fulfill the "stored in the traybar of Windows" requirement.
The Chrome App Launcher is the hub of all your Chrome apps and with it
you have quick access to all of your apps from the desktop. When you
install an app from the "For Your Desktop" collection of the Chrome
Web Store, you get the App Launcher. The App Launcher requires you to
sign in to Chrome to enable apps that need access to your Google
account.
Manage apps
When you download a new app that enables App Launcher, the apps from
your Apps bookmark on Chrome New Tab page will also appear in the App
Launcher. Managing apps in the App Launcher is simple.
Add more apps: Click the Chrome Web Store button in your apps list and explore the apps in the store.
...
Background: Extending Your App's Life
You mentioned background apps in your question but I would recommend you explore it further. It essentially provides the "prevent users from accidentally close my application" requirement that you stated. This isn't foolproof (see bold sentence below) but it is about as close to the requirement I think you will be able to achieve.
As of Google Chrome 10, the background feature lets a hosted app run
as soon as the user logs into their computer—before the user launches
Chrome or the app—and to continue running even when Chrome or the app
has no visible windows. However, if the user explicitly quits Chrome,
the browser and app both exit.