A URI association allows your app to auto-launch when a specific URI is launched from another app. For example, a game developer may want to allow users to launch into a specific game level from a URI that is sent via text message. The flexibility of this feature allows for additional information to be sent in the URI itself. For more info about URI associations, see Auto-launching apps using file and URI associations.

This sample includes three apps: a URI launcher and two apps to handle the URI schemes that are built in to the launcher app.

  • sdkURIAssociationWP8CS: Use this app to launch pre-set URIs for the fabrikam, contoso, and litware URI schemes. You can also use this app to launch custom URI schemes on the same phone and to other phones via Proximity. For more info about this app, see the Using the sample section.

  • ContosoHandlerApp: Use this app to handle the contoso URI scheme. When sdkURIAssociationWP8CS launches URIs with the contoso URI scheme, this app can automatically launch to handle the URI scheme. Note that the ContosoLitwareHandlerApp also handles the contoso URI scheme; when both apps are installed, the user will be presented with a menu to choose which app they want to open.

  • ContosoLitwareHandlerApp: Use this app to handle the contoso and litware URI schemes. When sdkURIAssociationWP8CS launches URIs with the contoso or litware URI scheme, this app can automatically launch to handle the URI scheme. Note that no other apps (from this sample) handle the litware URI scheme; when a litware URI is launched, this app will immediately launch to handle the URI scheme.

Important Note:

Before using the sample, deploy all three apps from the solution to your emulator/phone. For more info, see the following procedures.

Build the sample

  1. Start Visual Studio Express 2012 for Windows Phone and select File > Open > Project/Solution.

  2. Go to the directory in which you unzipped the sample. Double-click the Visual Studio Express 2012 for Windows Phone solution (.sln) file.

  3. Use Build > Rebuild Solution to build the sample.

Deploy the sample

All three apps in the sample—sdkURIAssociationWP8CS, ContosoHandlerApp, and ContosoLitwareHandlerApp—must be deployed to the emulator/phone for the sample to work as intended. This procedure describes one of the ways you can deploy all three apps to your emulator/phone.

  1. In Solution Explorer, right-click ContosoHandlerApp, then click Set as StartUp Project.

  2. In the Visual Studio toolbar, confirm that the appropriate debugging target is selected.

  3. Right-click ContosoHandlerApp again, and then click Deploy.

  4. In the Output window, confirm that the app was deployed to the intended target.

Repeat steps 1–4 for the other two apps in the sample: ContosoLitwareHandlerApp and sdkURIAssociationWP8CS.

Run the sample

  • Confirm that sdkURIAssociationWP8CS is set as the startup project.

  • To run the app with debugging, press F5 or use Debug > Start Debugging.

  • To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

Using the sample

Use the sdkURIAssociationWP8CS app to test URI associations on your phone or emulator. The app includes the following UI elements:

  • Launch Fabrikam URI scheme: Use this button to see what happens when no installed apps have registered to handle a URI association. The sample does not include an app to handle the fabrikam URI scheme, so the emulator/phone will ask if you want to want to search for apps in the Store. Note that at the time of this writing, no apps have registered to handle the fictitious fabrikam URI scheme.

  • Launch Litware URI scheme: Use this button to see what happens when only one installed app as registered to handle a URI association. The ContosoLitwareHandlerApp launches immediately to handle the litware URI scheme.

  • Launch Contoso URI scheme: Use this button to see what happens when multiple installed apps have registered to handle a URI association. The ContosoLitwareHandlerApp and the ContosoHandlerApp are registered to handle the contoso URI scheme. A menu appears to allow the user to choose which app to open.

  • current URI scheme: Use this text box to edit the current URI scheme or replace it with your own custom scheme. When you are finished editing, launch the URI by taping one of the launch buttons under it. Note that you can also use this to launch built-in apps. For example, ms-settings-wifi: can be used to launch the built-in Wi-Fi Settings app.

  • Launch current URI scheme: Use this button to launch the URI that is shown in the current URI scheme text box.

  • Launch current URI via Proximity: Use this button to launch the URI that is shown in the current URI scheme text box on another phone. Note that both phones must support NFC for this to work.