Context:
Our app recently switched to using Custom Chrome Tabs for authentication. WebViews wouldn't allow login from Google and Facebook due to privacy restrictions.
Everything worked well using onResume and onNewIntent lifecycle methods to detect when the user closes the Custom Chrome Tab and is redirected back to our app. However, a recent Chrome update introduced a minimize button (Picture-in-Picture mode) for Custom Chrome Tabs.
For our authentication flow, this minimize functionality is undesirable. We want the user to complete authentication before interacting with the app again. Unfortunately, modifying Chrome Tab behavior directly is limited due to privacy concerns.
Our current issue is that when the user minimizes the Custom Chrome Tab, our app using onResume interprets it as a complete closure. I've explored onMinimized and onUnMinimized APIs from CustomTabCallback, but they don't detect the scenario where the user minimizes and then closes the tab. This leaves our app's activity empty, resulting in a poor user experience.
Question:
- Are there ways to reliably detect when a minimized Custom Chrome Tab is finally closed by the user?
- Are there alternative solutions to effectively track the minimize functionality for our authentication process?
Additional Information:
I've explored onMinimized and onUnMinimized APIs from CustomTabCallback. To track the minimized state, I implemented a flag. However, this approach has limitations. Inside onResume, I use a timer (set to 750 milliseconds) to periodically check the flag. If the flag shows the tab is minimized, I avoid treating it as a closed tab. This introduces a slight delay in detecting the close event, and I'm curious if there are better solutions.
But as I said earlier this solution can resolve detecting the minimize state but when user closes the custom tab when it is in minimized state we dont have any way to detect.
Is there any way to detect the closing of custom tab in minimized state?
Thanks for any help!!