locked
Launching Specific content of Windows Store App from Web Application

    Question

  • Hi,

    Requirement: Launch to the specific content in windows store app(along with parameters required for launching) when hit in browser

    I have requirement like Bing News app. When mailed an article, Bing news app populates the following content(a sample)

    Ocean search for lost Malaysian jet shifts 1,100 km north
    Reuters - Reuters - ‎28‎ ‎March‎ ‎2014
    Australian authorities said on Friday they were shifting the focus of their Indian Ocean search for the wreckage of Malaysia's missing airliner, moving it more than 1,000 km to the north
    If you have Windows 8, open this in News. Otherwise, open in the browser.
    
    http://www.bing.com/r/1A/AWirh?a=1&m=en-in

    When I click on http://www.bing.com/r ..... I could see a pop up and on clicking of allow it launches into app with the specific content mailed here.

    I have followed  meta tags here  but when I navigate to html page I could see my app atleast doesnot launch.

    Could some one let me know what additional stuff should I add for getting worked

    Is it required to be done from a web application only or could it be launched from MVC or Web API too.


    Thanks & Regards Tejaswi Chandrapatla


    • Edited by Teja510 Tuesday, April 1, 2014 1:13 PM
    Tuesday, April 1, 2014 1:12 PM

Answers

  • If you're using a .NET server of some sort, make sure your html has:

    <head runat="server">

    And then put this function in codebehind, and call it with your own fancy uri:

    void AddMetaRefresh(int secondsToWait, string uri)
            {
                HtmlGenericControl c = new HtmlGenericControl("meta");
                c.Attributes.Add("http-equiv", "refresh");
                c.Attributes.Add("content", string.Format("{0};URL={1}", secondsToWait, uri));
                Header.Controls.Add(c);
            }

    Then, in codebehind on OnInit() do this:

    AddMetaRefresh(0, "YOUR://specialurihere/fromweb/reallycoolthings/etc.");

    You could also do it all on the aspx page itself, or you could even do it with jquery if you were using that on a document.ready (you don't have to use a meta refresh, a document.href could work..)

    If you make the URI's the same in each app, you don't really need browser detection between the two.  On a Windows phone, the system will launch your Windows Phone app, and when on Windows 8, it'll just launch your Windows app.



    Darin R.

    • Marked as answer by Teja510 Wednesday, April 2, 2014 11:35 AM
    Tuesday, April 1, 2014 4:45 PM

All replies

  • You can define a protocol for your app and then link to that URI. See How to handle URI activation (Windows Store apps using C#/VB/C++ and XAML)
    Tuesday, April 1, 2014 2:50 PM
    Owner
  • The documentation you refer to shows how to link to the app in the store. 

    Rob's correct in that to open to your APP (instead of the store) you have to use a URI within your app.

    The way Bing appears to be doing it is by meta refreshing the page like this:

    <META http-equiv="refresh" content="0;URL=bingnews://application/view?entitytype=article&pageId=0&contentId=258270024&market=en-in&referrer=share">

    I assume that Bing is also doing some browser user-agent sniffing to determine if the platform is windows 8 at least...  I'm not sure that this would work without error on all other browsers or platforms.


    Darin R.

    Tuesday, April 1, 2014 3:52 PM
  • Thanks both Darin and Rob.

    As Rob menitoned, I have a protocol for my app and works when I hit in Run or as hyper link in email

    I could not find which meta tag to use for the protocol( From Darin's mentioning I got the idea now).

    Darin, How could I make the parameters dynamic in content part of that meta tag?

    For ex: the content id in bing news vary. so how could I make it?

    and also is it possible to determine to redirect to wp8 app or win8 app based on browser being launched.

    I guess Bing news got some behaviour as mentioned above..

    where could i get some documentation as of the above for bing behaviour



    Thanks & Regards Tejaswi Chandrapatla


    • Edited by Teja510 Tuesday, April 1, 2014 4:12 PM
    Tuesday, April 1, 2014 4:11 PM
  • If you're using a .NET server of some sort, make sure your html has:

    <head runat="server">

    And then put this function in codebehind, and call it with your own fancy uri:

    void AddMetaRefresh(int secondsToWait, string uri)
            {
                HtmlGenericControl c = new HtmlGenericControl("meta");
                c.Attributes.Add("http-equiv", "refresh");
                c.Attributes.Add("content", string.Format("{0};URL={1}", secondsToWait, uri));
                Header.Controls.Add(c);
            }

    Then, in codebehind on OnInit() do this:

    AddMetaRefresh(0, "YOUR://specialurihere/fromweb/reallycoolthings/etc.");

    You could also do it all on the aspx page itself, or you could even do it with jquery if you were using that on a document.ready (you don't have to use a meta refresh, a document.href could work..)

    If you make the URI's the same in each app, you don't really need browser detection between the two.  On a Windows phone, the system will launch your Windows Phone app, and when on Windows 8, it'll just launch your Windows app.



    Darin R.

    • Marked as answer by Teja510 Wednesday, April 2, 2014 11:35 AM
    Tuesday, April 1, 2014 4:45 PM
  • Darin, Is there a way to detect whether app is installed or not. How about using navigator.MsnavigateUri(). I see this working fine in windows 8 app, but not windows store app.

    Here is the link for the same question I have posted

                
           

    Thanks & Regards Tejaswi Chandrapatla

    Tuesday, July 1, 2014 3:08 PM