Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QR code to trigger action on installed native app in windows phone

How can I trigger action on a windows phone app? Let say I want to navigate to a certain page in my native app by scanning the QR code, how do I go about doing that?

like image 369
Keenlearner Avatar asked Dec 06 '25 00:12

Keenlearner


1 Answers

First of all this is an idea, what i would do is to create a custom uri scheme, so when the QR code has been read, the device will navigate to the page you pointed, it doesn't matter if your application is running

  • in WMAppManifest right after Tokens add
  <Extensions>
  <Protocol Name="yourprotocol" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
  </Extensions>
  • than in App.cs add RootFrame.UriMapper = new CustomUriMapper();
  • in your case CustomUriMapper should look like this
class CustomUriMapper : UriMapperBase
{
    private string tempUri;
    public override Uri MapUri(Uri uri)
    {
        tempUri = System.Net.HttpUtility.UrlDecode(uri.ToString());          
        if (tempUri.Contains("yourprotocol"))
        { 
         return new Uri("YourPage.xaml", UriKind.Relative);
        }
        else
            {
                return new Uri("MainPage.xaml", UriKind.Relative);
            }           
    }
} 

Let me know how it goes (:

like image 160
Swift Sharp Avatar answered Dec 08 '25 14:12

Swift Sharp