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

MWA Not Functioning in WebViews/In App Browsers #1082

Open
Funkatronics opened this issue Jan 27, 2025 · 1 comment
Open

MWA Not Functioning in WebViews/In App Browsers #1082

Funkatronics opened this issue Jan 27, 2025 · 1 comment
Assignees

Comments

@Funkatronics
Copy link
Contributor

Local MWA connections from web dapps on Android will not always work if the app is being viewed in an in-app browser or webview. The MWA connection with a local mobile wallet app is imitated by launching a generic URI to open the wallet app and establish the MWA session with the dapp. These types of links (as well as deep links) are caught by Android Webview by default and not passed to the system to launch the app. Apps that are providing the in app browsing experience must choose to handle these types of links and launch an associated Android Intent if they want to enable this experience for their in-ap browsing context.

Explanation

Symptom

Opening a Solana Web Dapp in an in-app browser on Android (within Telegram, for example) and selecting "Mobile Wallet Adapter" from the wallet connection UI will route the user to the Solana Mobile Wallets webpage. The user expects their wallet app to be opened when they choose the Mobile Wallet Adapter option, but they are instead taken to the Solana Mobile Wallets where they are instructed to install an SMS compatible mobile wallet app.

Why It Happens

The wallet-adapter-mobile js library takes an optional onWalletNotFound handler that is called when the MWA intent fails to launch. The default onWalletNotFound handler implementation that is provided by the library assumes that the intent failed to launch because the user does not have a compatible mobile wallet app installed and routes users to the Solana Mobile Wallets webpage so they can install a compatible wallet app like Phantom or Solflare.

Workarounds

For Users

Users should open the web dapp in their mobile browsing app (Chrome, Edge, etc) on the Android device instead of trying to access the device from a non-browser apps in app browsing context. Local MWA connections will work on Android when the web app is run in a proper browser app like Chrome.

For Dapp Developers

Dapp developers cannot override this behavior to enable MWA connections in these contexts, but they can catch this error and provide and inform the user why MWA cannot be used. The UX here is up to the dapp, but we recommend displaying some kind of error to the user and instructing them to open the website in their browser app instead if they want to use MWA.

The wallet-adapter-mobile js library takes an optional onWalletNotFound handler that is called when the MWA intent fails to launch. The default implementation that is used will route users to the Solana Mobile Wallets webpage as described above. By providing your own handler, your dapp can decide how exactly it wants to handle this case. When this handler is called, you can determine if the user is running the page in a webview (by looking at the userAgent string for example) and provide guidance to the user. Note that you should also handle the case where the page is already running in a browser and instruct the user to install a mobile wallet app.

For App Developers with In-App Browsers

Apps with in-app browsers that wish to enable MWA connections from the in-app browser should be sure to catch and handle the MWA URI (solana-wallet:/...) in the WebView handler. The details of this will depend on the tech stack used for the application. For native Android applications, you will need to override the shouldOverrideUrlLoading and convert the URI to an Andorid intent as described in the Android developer docs here. See these SO posts for further examples:

@Funkatronics
Copy link
Contributor Author

Example of dapp handling in #1083. This is a basic example of how to catch this issue - Dapps should explore additional UX here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant