Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

App URI Handlers in UWP Apps: Open Your Website With Your App

DZone's Guide to

App URI Handlers in UWP Apps: Open Your Website With Your App

If you have a website and an app you might want people navigating to your website on a device with the app installed to instead go straight to the app. Matt Lacey has some advice for you!

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

All this month, I'm taking some time each day to explore (and document) things that are related to UWP development that I haven't fully investigated or used before. While doing it over lunch each day I'm calling it #UWPLunch.

If you have a website and an app you might want people navigating to your website on a device with the app installed to instead go straight to the app.

If that's what you want it's easy to do.

You just need to tell your app which website. It's just a little addition to the manifest:


Ignore the colored wiggly lines indicate that you need to declare the uap3 namespace alias:

xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"

Also, add it to the IgnorableNamespaces list.

Then you tell the website about the app. Add a file named ' windows-app-web-link' to the root of the site that returns JSON like the following.

  "packageFamilyName": "mrlaceycom_thnpmr8zdxbza",

  "paths": [ "*" ],

  "excludePaths" : [ "/about*" ]

When the app is Activated you can detect being launched this way by checking for activation of the kind  ActivationKind.Protocol and then query the Uri to get the path that would have been viewed on the website.

You'll find more on this and another example at
https://blogs.windows.com/buildingapps/2016/10/14/web-to-app-linking-with-appurihandlers/

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
app ,development ,uwp

Published at DZone with permission of Matt Lacey, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}