-
Notifications
You must be signed in to change notification settings - Fork 965
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
Phantom's in-app browser not opening on iOS #814
Comments
Okay I've done some digging On your link, the behaviour I'm seeing is:
Obviously there are a lot of things that could be causing this, so I've done some tests to try to narrow it down a bit First, here's a codesandbox with two buttons that deeplink into Phantom/Solflare respectively using the same JS as wallet-adapter: https://zfn6gj.csb.app/ . This works correctly, nothing stops me going phantom - back - phantom - back - phantom. So it's probably not a wallet issue, or a limitation of iOS redirects/universal links Second I modified our starter/example app to add Phantom + Solflare adapters. When I open this with iOS I find:
I think that the behaviour I'm seeing on your site is consistent with that when using the dialog/modal button and selecting Phantom/Solflare. Without seeing your code it's hard to know exactly what would get the behaviour that you expect, or if there's a bug here. But speculating a bit, here's what I think is probably happening:
But even if it did call But this should only be an issue if there is already a localstorage key containing a previously selected wallet, and you select the same one again. For apps like yours where storing the wallet name doesn't make sense (since you're not using autoconnect or displaying the connected wallet in the UI), it might make sense for us to add an option to You can verify this by using Safari to debug your page, if you delete the |
I also faced that problem.
@mcintyre94 thanks for your dive into it, it really looks logical and makes it clear! For your understanding that's how I'm using it: // app.ts
import { ConnectionProvider, WalletProvider } from "@solana/wallet-adapter-react";
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
export default function app() {
// ...
const network = WalletAdapterNetwork.Mainnet;
const wallets = useMemo(
() => [
new PhantomWalletAdapter(),
new SolflareWalletAdapter(),
new TorusWalletAdapter(),
new MathWalletAdapter(),
new Coin98WalletAdapter(),
new CloverWalletAdapter(),
new HuobiWalletAdapter(),
new CoinbaseWalletAdapter(),
new BitKeepWalletAdapter(),
new NekoWalletAdapter(),
new TrustWalletAdapter(),
new NightlyWalletAdapter(),
new SalmonWalletAdapter(),
new FoxWalletWalletAdapter(),
],
[network]
);
return (
// ...
<ConnectionProvider>
<WalletProvider wallets={wallets} autoConnect>
<WalletModalProvider>
{/* ... */}
</WalletModalProvider>
</WalletProvider>
</ConnectionProvider>
)
} And that's my ConnectWallet component that triggers the modal. // connect wallet button
import { useWalletModal } from "@solana/wallet-adapter-react-ui";
export const ConnectWallet = () => {
// ...
const { setVisible, visible } = useWalletModal();
return (
// ...
<button
onClick={() => {
setVisible(true);
}}
type="button"
>
{connecting ? t`Connecting...` : t`Connect wallet`}
</button>
)
} @mcintyre94 let me know please if that info helps you identify the problem. Tbh I'm not sure I can ask you for anything, since seems like you're not the part of team. If I'm correct, please let me know, so I'll understand if I need to address it to someone else or try to fix myself :) |
Any updates on this? |
I'm stuck here too... My code looks exactly the same as above (with just PhantoWallet). This code works great on a laptop with the Chrome extension but on my iphone it throws my app into the Phantom Wallet app and the modal overlay never triggers off. Here's a link https://deadco.info/sphere (don't worry there's no transactions going on ...) I'm just trying to connect to get the public key so I can send it to my server for a claim. i want to launch this during the Dead and Company shows in Las Vegas.
Source for the component is here |
I can't get the example to run. If I do an npm install it complains about 'workspace:' not being set I see it's used in the package.json but do I need to set it for each package? |
Faced the same issue, which complicated stuff in my dapp. Read through the whole tread and the |
Have to update you on my last comment, this is not the case, I implemented a fix in my dapp which removes |
Ok, so I actually found out the issue, it's here: if (this._readyState !== WalletReadyState.Unsupported) {
if (isIosAndRedirectable()) {
// when in iOS (not webview), set Phantom as loadable instead of checking for install
this._readyState = WalletReadyState.Loadable;
this.emit('readyStateChange', this._readyState);
} else {
scopePollingDetectionStrategy(() => {
if (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) {
this._readyState = WalletReadyState.Installed;
this.emit('readyStateChange', this._readyState);
return true;
}
return false;
});
}
} What this does is basically it sets the walletsToCheck.forEach(({ name, globalObject }) => {
if (localStorageWallet === name && globalObject === undefined) {
localStorage.removeItem('walletName')
const wallet = wallets.find((wallet) => wallet.adapter.name === name)
if (wallet) {
wallet.adapter.disconnect()
}
}
}) in Phantom case:
What's sad is that it still doesn't work for Android as Phantom only has the |
Describe the bug
Trying to connect Phantom wallet in safari browser on mobile, and Phantom's in-app browser is not opening. I'm required to click Solflare from the list of wallets (which is not installed), redirected to Solflare's website and on trying again after coming back to the initial page Phantom as an option works fine.
To Reproduce
Steps to reproduce the behavior:
Note - If Phantom works for you in the first try and the payment page opens up in it's in-app browser, please come back to the payment page in your browser and try clicking on Phantom again and it will not work in the second try, which is unexpected behaviour and not great for UX in case user wasn't able to connect wallet in first try for some reason.
Screenshots
https://github.com/solana-labs/wallet-adapter/assets/91828247/4385eb0b-658a-411a-834e-622a561911d9
Smartphone
The text was updated successfully, but these errors were encountered: