Win10 UWP URI Scheme (i): parsing and using the Windows store protocol

Source: Internet
Author: User

Protocols are an important feature of Windows Phone and Windows store apps that make calls to each other from one application to another. A little agreement, a great deal of learning. I'm going to write a few articles about the protocol used in the UWP.

The main object of this talk is the associated launch protocol Ms-windows-store supported by the WIN10 system's own store app.

I. How the Ms-windows-store protocol is invoked

The Ms-windows-store protocol supports calls within a Web or UWP app, and can be started directly from the App store that comes with the system.

1. Launch the App Store via the web

You may notice that when we open a URL link to a Win10 app in the browser, the App store that comes with the system will be transferred, and the trick is to use the Ms-windows-store protocol!

For example, the following UWP app: https://www.microsoft.com/store/apps/9nblggh5x991

(By the way, my newest UWP app--the gift says--the most beautiful collection of things)

Use F12 Dafa to view the source of this page, you will find the following code

1<iframe id= "Cli_redirectframe" class= "hidden" ></iframe>2<script>3 Onestoreredirect (Onestoreuseragent (), document)4. AUTOREDIRECTTONATIVESTOREPDP ("Cli_redirectframe", {5              "  Threshold": "Ms-windows-store://pdp/?productid=9nblggh5x991\u0026referrer=unistoreweb", 6"win8x": "MS-WINDOWS-STORE:PDP?" Pfn=39014appchampionstudio.-_ttcpf2hpawt8p\u0026referrer=unistoreweb ",7"phone81": "Ms-windows-store:navigate?appid=ddc54195-22fd-43f3-ab67-964ca250bd6c\u0026referrer=unistoreweb",8"phone807x": "Zune://navigate/?appid=ddc54195-22fd-43f3-ab67-964ca250bd6c\u0026referrer=unistoreweb"9}, ' 9nblggh5x991 ',false, ' The gift says--the most beautiful thing to collect ',true,true,false,false);Ten</script>

This code is automatically executed when the page is loaded, to automatically invoke the Ms-windows-store protocol, try to start the App Store app, and navigate to the specific application page:

The method of using the protocol in the web is very simple, simply by analogy the URL of the Ms-windows-store protocol into an HTTP protocol to request it.

2. Launch the store in the UWP app

In a UWP app, you can also start the App Store on your system. In fact, any protocol can be tried using the following API to invoke:

1 await Windows.System.Launcher.LaunchUriAsync (new Uri (Inputuri));

In fact, the role of "ms-windows-store://" is equivalent to "http://", Ms-windows-store is a custom uri Scheme, followed by the parameter rules strictly in accordance with the URI format.

Of course the UWP app (actually the App Store is also a UWP app) can claim that the UWP supports a custom protocol (such as Myscheme) in Package.appxmanifest's "claims", so long as it is anywhere (Web, UWP app, IOS app, Android app, or even your own UWP) call (myscheme://, note with "//"), this UWP can be started up. From the life cycle perspective of the UWP, it should not be called "Start (Launch)", but should be "activated (Activated)" up. App.cs can use the Onactivated method to receive the URI parameters in the custom protocol to parse itself and make the page navigation processing. This part of the content we leave to the next specific launch.

Two. High-end usage of the Ms-windows-store protocol

The topic we're talking about is the App Store protocol, which says a lot of the details of starting a store into an application are far from satisfying our usual development needs, and you may need to ask for a good rating.

The MSDN documentation provides a very detailed introduction to Ms-windows-store, Links: https://msdn.microsoft.com/en-us/library/windows/apps/mt228343.aspx

Describe Important parameters URI Scheme
Start to shop Home

Ms-windows-store://home

ms-windows-store://<---If you can only write this in a UWP app

Start a category to the store

(Not all categories are visible to all users, current category has apps, games, music, videos)

Path Navigatetopage

ms-windows-store://navigatetopage/? Id=apps

ms-windows-store://navigatetopage/? Id=games

ms-windows-store://navigatetopage/? Id=music

ms-windows-store://navigatetopage/? Id=video

Launch to an app details

Path PDP (Product detail page)

ProductId,ProductId,ProductId

(Important parameters say three times, UWP most recommended way)

Ms-windows-store://pdp/? productid=9nblggh5x991
PFN(pacakge Family Name) Ms-windows-store://pdp/? pfn= Microsoft.Office.OneNote_8wekyb3d8bbwe
Phoneappid (Windows Phone 7.x/8.x) Ms-windows-store://pdp/? phoneappid=ca05b3ab-f157-450c-8c49-a1f127f5e71d
AppId (Windows 8.x) Ms-windows-store://pdp/? appid=f022389f-f3a6-417e-ad23-704fbdf57117

Start writing a comment to an app

Path Review, Reviewapp (Windows Phone 7.x/8.x)

ProductId,ProductId,ProductId

(Important parameters say three times, UWP most recommended way)

ms-windows-store://review/? productid=9nblggh5x991
PFN ms-windows-store://review/? pfn= Microsoft.Office.OneNote_8wekyb3d8bbwe
AppId (Windows Phone 7.x/8.x) ms-windows-store://Reviewapp/? appid=ca05b3ab-f157-450c-8c49-a1f127f5e71d
AppId (Windows 8.x) ms-windows-store://review/? appid=f022389f-f3a6-417e-ad23-704fbdf57117

Start an association search

Path Assoc

Fileext(products that are associated with file extension) Ms-windows-store://assoc/? Fileext=pdf

Protocol (products associated with the agreement) Ms-windows-store://assoc/? Protocol=liwushuo

Tags (products associated with tags) Ms-windows-store://assoc/? Tags=photos_rich_media_edit, Camera_capture_app

Start Search

Path Search

Ms-windows-store://search/?query=onenote

Product Search in the startup category

Path Browse

Ms-windows-store://browse/?type=apps&cat=productivity

Ms-windows-store://browse/?type=apps&cat=health+%26+fitness

Launch a product search published by a publisher (spaces are allowed in the name)

Path publisher

Ms-windows-store://publisher/?name=appchampion Studio

Start the Download and update page

Ms-windows-store://downloadsandupdates

Start the Store Settings page

Ms-windows-store://settings

The rules for the Ms-windows-store protocol above apply to WIN10 UWP apps, and some rules WP or win8.x do not apply.

Summary

The topic of this lecture is the rules of the WIN10 App Store-related protocols, and introduces the basic principles of URI scheme. Next we talk about the use of URI scheme in the UWP, parsing the response, and where it applies.

Win10 UWP URI Scheme (i): parsing and using the Windows store protocol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.