AppUriHandler not working for host starting with '*.' while using uap5

R, Rashmi 6 Reputation points
2020-06-16T07:20:28.647+00:00

Hi Team,

I am trying to enable my app for websites using app uri handlers.
I am following this documentation :
https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap5-host

I have given the appurihandler details as below:
<uap3:AppUriHandler>
<uap5:Host Name="*.crm.dev.com" />
</uap3:AppUriHandler>

But i get a warning: The element 'AppUriHandler' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/3' has invalid child element 'Host' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/5'. List of possible elements expected: 'Host' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/3'

And when I click on the link: (https://abc123.crm.dev.com/answers), the app does not launch and the link is opened on the browser.

Please let me know what is causing the issue here. I have followed exactly as shown in the documentation mentioned above.

Thanks and Regards,
Rashmi R

Universal Windows Platform (UWP)
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Richard Zhang-MSFT 6,936 Reputation points
    2020-06-16T11:46:59.687+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Please refer to this document for handling URLs with apps: Enable apps for websites using app URI handlers.

    In the sample code, uap5 namespace is not required.

    This is a simple code example:

    <Package  
      ...  
      xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"  
      IgnorableNamespaces="uap mp uap3">  
    <Applications>  
      <Application ... >  
          ...  
          <Extensions>  
             <uap3:Extension Category="windows.appUriHandler">  
              <uap3:AppUriHandler>  
                <uap3:Host Name="msn.com" />  
              </uap3:AppUriHandler>  
            </uap3:Extension>  
          </Extensions>  
      </Application>  
    </Applications>  
    </Package>  
      
    

    In addition, you also need to add the handling of OnActivated life cycle events in App.xaml.cs, in which to respond to the launch through Uri

    protected override void OnActivated(IActivatedEventArgs e)  
    {  
        Frame rootFrame = Window.Current.Content as Frame;  
        if (rootFrame == null)  
        {  
            ...  
        }  
      
        // Check ActivationKind, Parse URI, and Navigate user to content  
        Type deepLinkPageType = typeof(MainPage);  
        if (e.Kind == ActivationKind.Protocol)  
        {  
            var protocolArgs = (ProtocolActivatedEventArgs)e;          
            switch (protocolArgs.Uri.AbsolutePath)  
            {  
                case "/":  
                    break;  
                case "/index.html":  
                    break;  
                case "/sports.html":  
                    deepLinkPageType = typeof(SportsPage);  
                    break;  
                case "/technology.html":  
                    deepLinkPageType = typeof(TechnologyPage);  
                    break;  
                case "/business.html":  
                    deepLinkPageType = typeof(BusinessPage);  
                    break;  
                case "/science.html":  
                    deepLinkPageType = typeof(SciencePage);  
                    break;  
            }  
        }  
      
        if (rootFrame.Content == null)  
        {  
            // Default navigation  
            rootFrame.Navigate(deepLinkPageType, e);  
        }  
      
        // Ensure the current window is active  
        Window.Current.Activate();  
    }  
    

    After that, you can press the Win+R key combination and enter the URL to check whether it takes effect.

    Thanks.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.