Skip to content

Phantom does not send back response after select connect聽#20

Description

@baileyalo

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()}`);
}

Activity

  1. Timadigwe commented on Nov 5, 2022

    @Timadigwe

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

  2. faisal-dropchain commented on May 17, 2023

    @faisal-dropchain

    @Timadigwe how did you fix this issue?

  3. Timadigwe commented on May 17, 2023

    @Timadigwe

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

  4. Timadigwe commented on May 17, 2023

    @Timadigwe

    Use Solana mobile stack or expo flow
    It works on expo

  5. faisal-dropchain commented on May 17, 2023

    @faisal-dropchain

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions