imamuu
imamuu

Reputation: 41

Unable to redirect to app from WebViewClient with custom URI scheme on Android 11

I would like to implement Twitter's social login function in an Android app developed based on Flutter, but after logging in with WebView, the redirect to the app using custom URI scheme does not work as follows.

The Android 10 (API 29) emulator succeeds in redirecting. However, in the Android 11 (API 30) emulator, the redirect after issuing the token on Twitter will be webpage not availabele net :: ERR_UNKNOWN_URL_SCHEME.

I think that the definition on AndroidManifest.xml is correct because it can be redirected in API29. Is there any change in Android11?

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <!-- Registered Callback URLs in TwitterApp -->
    <data android:scheme="app_name"/> <!-- host is option -->
</intent-filter>

The redirect URI is in the form app_name: //? Oauth = hogehoge ...

Since the Webview screen itself is different between API 29 and API 30, I think that there is a specification change around here, but I couldn't find out what is actually the problem even after I look at the changes between android 10 and 11.

This is the problem about the redirect part, so I think that something is going on in the part that depends on Android rather than Flutter.

This is the result of executing Flutter doctor -v.

[✓] Flutter (Channel stable, 2.5.1, on Mac OS X 10.14.6 18G9323 darwin-x64,
    locale ja-JP)
    • Flutter version 2.5.1 at /Users/myname/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffb2ecea52 (11 days ago), 2021-09-17 15:26:33 -0400
    • Engine revision b3af521a05
    • Dart version 2.14.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/myname/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android
        Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
        🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
        🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.60.2)
    • VS Code at /Users/myname/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.26.0


[✓] Connected device (2 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API
        30) (emulator)
    • Chrome (web)            • chrome        • web-javascript • Google Chrome
        93.0.4577.82

The emulator that didn't work was the Pixel 4 API 30 with Play Store. What worked was the Pixel 3a API 29 with Play Store.

Upvotes: 4

Views: 818

Answers (0)

Related Questions