- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.4k
 
feat: Allow deeplinking from within in-app browser #22012
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
          
     Open
      
      
            smilingkylan
  wants to merge
  8
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
inapp-deep-links
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +227
        
        
          −13
        
        
          
        
      
    
  
Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | 
           CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.  | 
    
          
 | 
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    


Description
This PR fixes an issue where MetaMask deeplinks clicked within the in-app browser or carousel banners were redirecting users to the app store instead of navigating internally within the app.
Problem
When users clicked MetaMask deeplinks (e.g.,
https://link.metamask.io/swap,metamask://dapp/uniswap.org) from within the app:This occurred because these URLs were being passed to the OS linking system (
Linking.openURL()), which would try to open MetaMask again, resulting in an app store redirect since the app was already running.Solution
The fix intercepts MetaMask deeplinks and routes them through
SharedDeeplinkManagerfor internal handling:isInternalDeepLink) to identify MetaMask URLs that should be handled internallyonShouldStartLoadWithRequestand usebrowserCallBackfor in-browser navigationThe
browserCallBackmechanism allows deeplinks that should stay in the browser (e.g.,dapp://URLs) to navigate the current WebView tab, while other deeplinks (e.g.,swap,buy-crypto) navigate to their respective app screens.Changelog
CHANGELOG entry: Fixed MetaMask deeplinks clicked within the in-app browser or carousel banners redirecting to the app store instead of navigating internally
Related issues
Fixes: #[ISSUE_NUMBER]
Manual testing steps
Additional Testing Steps:
Browser Test Page: Create an HTML page with test links covering:
https://link.metamask.io/dapp/uniswap.orgmetamask://dapp/app.aave.com,dapp://curve.fihttps://link.metamask.io/swap,/buy-crypto,/homehttps://ethereum.org(control group)Unit Tests: Run
yarn jest app/util/deeplinks/index.test.tsTypeScript: Run
yarn lint:tscto verify type safetyScreenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Route internal MetaMask deeplinks to in-app handling in Browser and Carousel, opening only external URLs via OS, with new util and tests.
isInternalDeepLinkutil to detect MetaMask deeplinks; exposeshouldOpenExternally.SharedDeeplinkManager.parsefor internal links andLinking.openURLfor external ones.app/components/Views/BrowserTab/BrowserTab.tsx:onShouldStartLoadWithRequest; handle withSharedDeeplinkManager.parseusing{ origin: 'in-app-browser', browserCallBack }; prevent WebView load.app/components/UI/Carousel/index.tsx:openUrl; use{ origin: 'carousel' }when parsing internal.app/core/AppConstants.ts: addDEEPLINKS.ORIGIN_CAROUSEL.app/util/deeplinks/index.test.ts: add comprehensive tests forisInternalDeepLink.app/components/UI/Carousel/index.test.tsx: mockLinking, assert external opens viaLinkingand internal viaSharedDeeplinkManagerwithAppConstants.DEEPLINKS.ORIGIN_CAROUSEL.Written by Cursor Bugbot for commit 191fdce. This will update automatically on new commits. Configure here.