phantom / deep-link-demo-app

151 stars 25 forks source link

Phantom does not send back response after select connect #20

Open baileyalo opened 2 years ago

baileyalo commented 2 years ago

code snipet 👍 useEffect(() => { const initializeDeeplinks = async () => { const initialUrl = await Linking.getInitialURL(); if (initialUrl) { setDeepLink(initialUrl); } }; initializeDeeplinks(); const listener = Linking.addEventListener('url', handleDeepLink); return () => { listener.remove(); }; }, []);

const handleDeepLink = ({url}: Linking.EventType) => setDeepLink(url);

// Handle in-bound links useEffect(() => { if (!deepLink) { return; }

const url = new URL(deepLink);
const params = url.searchParams;

// Handle an error response from Phantom
if (params.get('errorCode')) {
  const error = Object.fromEntries([...params]);
  const message =
    error?.errorMessage ??
    JSON.stringify(Object.fromEntries([...params]), null, 2);
  console.log('error: ', message);
  return;
}

// Handle a `connect` response from Phantom
if (/onConnect/.test(url.pathname)) {
  const sharedSecretDapp = nacl.box.before(
    bs58.decode(params.get('phantom_encryption_public_key')!),
    dappKeyPair.secretKey,
  );
  const connectData = decryptPayload(
    params.get('data')!,
    params.get('nonce')!,
    sharedSecretDapp,
  );
  setSharedSecret(sharedSecretDapp);
  setSession(connectData.session);
  setPhantomWalletPublicKey(new PublicKey(connectData.public_key));
  console.log(`connected to ${connectData.public_key.toString()}`);
}
Timadigwe commented 1 year ago

Same here , when i click the connect button it doesnt redirect back to the app nor return a response

faisal-dropchain commented 1 year ago

@Timadigwe how did you fix this issue?

Timadigwe commented 1 year ago

It didn't work for me I used Solana mobile stack

Timadigwe commented 1 year ago

Use Solana mobile stack or expo flow It works on expo

faisal-dropchain commented 1 year ago

mmh but solana mobile stack uses Mobile Wallet Adapter(MWA) and that doesnt work with IOS!