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

[Bug]: Android future never return when close web view #87

Open
2 tasks done
dagovalsusa opened this issue Dec 5, 2023 · 6 comments
Open
2 tasks done

[Bug]: Android future never return when close web view #87

dagovalsusa opened this issue Dec 5, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@dagovalsusa
Copy link

Description

Hi,

on Android the authenticate future never return when close web view, I have tried also catching error, but nothing e never return.

Minimal Reproduction

Steps to reproduce the behaviour:

  1. Use the following code:
    try {
      log("HERE bis $result");
      result = await FlutterWebAuth2.authenticate(
          url: url.toString(), callbackUrlScheme: 'myscheme', options: FlutterWebAuth2Options(timeout: 100, preferEphemeral: true, intentFlags: ephemeralIntentFlags));
      log("HERE tris $result");
    } catch (e, s) {
      log("HERE catch $result");
      FirebaseCrashlytics.instance.recordError(e, s);
      PlatformException exc = (e as PlatformException);
      if (exc.code == "CANCELED") return;
    }

Exception or Error

no error logs

Expected Behaviour

I will expected a null value, or a exception

Screenshots

No response

Additional context

No response

Device

Android Emulator Pixel 4

OS

Android

Browser

Chrome

Flutter version

3.16

flutter_web_auth_2 version

3.0.4

Checklist

  • I have read and followed the entire troubleshooting guide and it has not provided the solution I need.
  • I have provided all the information I can.
@dagovalsusa dagovalsusa added the bug Something isn't working label Dec 5, 2023
@ThexXTURBOXx
Copy link
Owner

As described in the documentation, timeout does not work on Android.
Did you follow all the setup steps as described here?

@dagovalsusa
Copy link
Author

dagovalsusa commented Dec 5, 2023

Yes, I have setup all steps, also on AndroidManifest.

<application
        android:label="------"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:usesCleartextTraffic="false"
        android:debuggable="false"
        android:allowBackup="false">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="https" />
                <data android:host="my host" />
            </intent-filter>
        </activity>

        <activity
        android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
        android:exported="true">
            <intent-filter android:label="flutter_web_auth_2">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="myscheme" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:exported="false"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>


        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

@tinu2610
Copy link

webview disappear when I press recent app or home button in android device.
final result = await FlutterWebAuth2.authenticate(
url: url, callbackUrlScheme: Constants.callbackUrlScheme,
options: const FlutterWebAuth2Options(intentFlags: ephemeralIntentFlags),
);

@ThexXTURBOXx
Copy link
Owner

@tinu2610 You are using ephemeralIntentFlags.
This is exactly the intended behaviour when using those.

@tinu2610
Copy link

tinu2610 commented Dec 12, 2023

@ThexXTURBOXx then how can I avoid that situation.
I don't want multiple instances of webview.
if i'm using ephemeralIntentFlags then after switching my original app with another app the WebView will completely disappear.

As linkedln using within app webview can we use same as from this package.

@ThexXTURBOXx
Copy link
Owner

This is a question you should be asking on Stack Overflow. Please don't hijack issues on GitHub for questions like these. This makes it hard for maintainers to keep track of real issues within their packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants