How to: Extend Search with App Connect for Windows Phone
March 22, 2012
With Windows Phone OS 7.1, applications can use App Connect to extend the Search experience on Windows Phone. This topic describes how to create an App Connect-enabled application and test it with various quick cards: product cards, place cards, and movie cards. The application featured in this topic extracts parameters from the App Connect deep link URI and displays them on an application page. For more information about using App Connect to extend the search experience, see Search Extensibility Overview for Windows Phone.
Important Note: |
|---|
Applications that abuse App Connect risk being pulled from the Marketplace. Register only for search extensions that are relevant to your application. To learn more about which extensions Bing associates with various quick cards, experiment with the Quick Card Sample. The purpose of App Connect is to save the user time. Applications must use the App Connect URI parameters in a meaningful way. For example, use App Connect to automatically search within your own application when launched from a quick card. Use the Quick Card Sample to learn more about the URI parameter values that are passed from quick cards. For a list of all available extensions and the URI parameters associated with each quick card, see Search Registration and Launch Reference for Windows Phone. |
This topic covers the following major steps:
Tip: |
|---|
This topic corresponds to the Quick Card Sample. To download the complete application, see Code Samples for Windows Phone. |
In the process, you will modify or create the following files:
WMAppManifest.xml: Modify the application manifest file to specify the search extensions corresponding to the application.
Extensions\Extras.xml: Create this file to specify the application title and caption that will appear in the apps pivot page of the corresponding quick card.
App.xaml: Modify this file to specify the URI mapping from the quick card deep link to the quick card target page.
App.xaml.cs: Modify this file to enable URI mapping in the application.
Model\QuickCardUriParameters.cs: Create this class file to represent a parameter in an App Connect deep link URI. This class implements theINotifyPropertyChanged interface.
ViewModel\QuickCardViewModel.cs: Create this class file to represent the ViewModel of the quick card target page. This class extracts the parameters from the App Connect deep link URI and implements the INotifyPropertyChanged interface.
QuickCardTargetPage.xaml: Create the quick card target page and modify the XAML code to present the parameters from the deep link URI. With respect to the MVVM pattern, this page is the view.
QuickCardTargetPage.xaml.cs: Modify this page to create the ViewModel object and load the parameters into the ViewModel when the page loads.
MainPage.xaml: Modify this page to present text for a standard application launch. This page is not launched by App Connect.
The application created in this topic uses a Model-View-ViewModel (MVVM) pattern. For another example of an MVVM application, see Implementing the Model-View-ViewModel Pattern in a Windows Phone Application.
Note: |
|---|
The steps in the following procedure are for Visual Studio 2010 Express for Windows Phone. You may see some minor variations in menu commands or window layouts when you are using the add-in for Visual Studio 2010 Professional or Visual Studio 2010 Ultimate. |
In this section, you create the application and modify the application manifest file to specify the search extensions that are relevant to your application. In this example, three extensions are specified to demonstrate the three types of quick cards. For a list of all extensions, see Search Registration and Launch Reference for Windows Phone.
To configure the application manifest
-
In Visual Studio 2010 Express for Windows Phone, create a new project by selecting the File | New Project menu command.
-
The New Project window is displayed. Expand the Visual C# templates, and then select the Silverlight for Windows Phone templates.
-
Select the Windows Phone Application template. Fill in the Name box with a name of your choice.
-
Click OK. The New Windows Phone Application window is displayed.
-
In the Target Windows Phone Version menu, ensure that Windows Phone 7.1 is selected.
-
Click OK. A new project is created, and MainPage.xaml is opened in the Visual Studio designer window.
-
In Solution Explorer, expand Properties and double-click WMAppManifest.xml. This opens the application manifest file.
-
In WMAppManifest.xml, add the following code to the App element, below the Tokens element.
<Extensions> <!-- Production extensions, for products: video games --> <Extension ExtensionName="Bing_Products_Video_Games" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}" TaskID="_default" ExtraFile="Extensions\\Extras.xml" /> <!-- Production extensions, for movies. --> <Extension ExtensionName="Bing_Movies" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}" TaskID="_default" ExtraFile="Extensions\\Extras.xml" /> <!-- Production extensions, for places: travel, food, and dining. --> <Extension ExtensionName="Bing_Places_Food_and_Dining" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}" TaskID="_default" ExtraFile="Extensions\\Extras.xml" /> </Extensions>This code adds three extensions, one for each type of quick card: product card, movie card, and place card. A quick card that is not associated with these extensions will not surface this application in the apps pivot pages corresponding to the quick card. For a complete list of search extensions, see Search Registration and Launch Reference for Windows Phone.
In this section, you create the Extras.xml file and specify the application title and caption that will appear in the apps pivot page of the corresponding quick card.
To create the Extras.xml file
-
In Solution Explorer, right-click your project and select Add, then New Folder.
-
Name the new folder Extensions.
-
In Solution Explorer, right-click the Extensions folder and select Add, then New Item.
-
In the Add New Item window, select XML File and name the file Extras.xml. Then click Add.
-
In Extras.xml, replace the code with the following.
<?xml version="1.0" encoding="utf-8" ?> <ExtrasInfo> <!-- Application title --> <AppTitle> <default>Display App Connect URI Parameters</default> </AppTitle> <!-- Search-related captions --> <Consumer ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}"> <!-- Products caption for video games --> <ExtensionInfo> <Extensions> <ExtensionName>Bing_Products_Video_Games</ExtensionName> </Extensions> <CaptionString> <default>Product URI Details</default> </CaptionString> </ExtensionInfo> <!-- Movies caption --> <ExtensionInfo> <Extensions> <ExtensionName>Bing_Movies</ExtensionName> </Extensions> <CaptionString> <default>Movie URI Details</default> </CaptionString> </ExtensionInfo> <!-- Places caption for food and dining --> <ExtensionInfo> <Extensions> <ExtensionName>Bing_Places_Food_and_Dining</ExtensionName> </Extensions> <CaptionString> <default>Place URI Details</default> </CaptionString> </ExtensionInfo> </Consumer> </ExtrasInfo>This code specifies how the application title and captions will appear in the apps pivot page, depending the type of quick card. In the apps pivot page for all quick cards, the application title will be Display App Connect URI Parameters. The caption will be different, depending on the type of quick card:
For product cards (associated with the Bing_Products_Electronics extension): Product URI Details
For movie cards (quick cards associated with the Bing_Movies extension): Movie URI Details
For place cards (associated with the Bing_Places_Food_and_Dining extension): Place URI Details
In this section, you will map the URI from the quick card deep link to the quick card target page. This will be accomplished by creating a quick card URI-mapper class and assigning it to the application frame in the app.xaml.cs file. Note that the quick card target page is created later in this topic, in the section Creating the Quick Card Target Page.
The URI-mapper class created in this section modifies the URI by replacing “SearchExtras” with the name of the page in your application that is to be launched. It also re-encodes each of the URI parameter values, handling any special characters that could be sent from the quick cards.
Tip:
|
|---|
|
This topic corresponds to the Quick Card Sample. To download the complete application, including the URI-mapper class named QuickCardUriMapper, see Code Samples for Windows Phone. |
To Create the URI-mapper Class
-
In Solution Explorer, right-click your project and select Add, then New Item.
-
In the Add New Item window, select Class and name the file QuickCardUriMapper.cs. Then click Add.
-
In QuickCardUriMapper.cs, replace the list of directives with the following.
-
In QuickCardUriMapper.cs, update the class statement so that it will inherit from the UriMapperBase class, as follows.
-
In the QuickCardUriMapper class, add the following code. This code re-encodes each of the App Connect URI parameter values. The destination page of the URI is determined by the static string named TargetPageName.
// Navigation destination. private static string TargetPageName = "QuickCardTargetPage.xaml"; private string tempUri; public override Uri MapUri(Uri uri) { tempUri = uri.ToString(); // Parse URI when launched by App Connect from Search if (tempUri.Contains("/SearchExtras")) { // Decode all characters in the URI. tempUri = HttpUtility.UrlDecode(tempUri); // Create a new URI for product cards. if (tempUri.Contains("Bing_Products")) { return GetProductCardUri(tempUri); } // Create a new URI for place cards. if (tempUri.Contains("Bing_Places")) { return GetPlaceCardUri(tempUri); } // Create a new URI for movie cards. if (tempUri.Contains("Bing_Movies")) { return GetMovieCardUri(tempUri); } } // Immediately return the URI when it is not related to App Connect for Search. return uri; } // Return a parsed Product Card URI. private Uri GetProductCardUri(string uri) { // Extract parameter values from URI. string ProductNameValue = GetURIParameterValue("ProductName=",uri); string CategoryValue = GetURIParameterValue("Category=",uri); // Create new URI. string NewURI = String.Format("/{0}?ProductName={1}&Category={2}", TargetPageName, ProductNameValue, CategoryValue); return new Uri(NewURI, UriKind.Relative); } // Return a parsed Place Card URI. private Uri GetPlaceCardUri(string uri) { // Extract parameter values from URI. string PlaceNameValue = GetURIParameterValue("PlaceName=", uri); string PlaceLatitudeValue = GetURIParameterValue("PlaceLatitude=", uri); string PlaceLongitudeValue = GetURIParameterValue("PlaceLongitude=", uri); string PlaceAddressValue = GetURIParameterValue("PlaceAddress=", uri); string CategoryValue = GetURIParameterValue("Category=", uri); // Create new URI. string NewURI = String.Format("/{0}?PlaceName={1}&PlaceLatitude={2}&PlaceLongitude={3}&PlaceAddress={4}&Category={5}", TargetPageName, PlaceNameValue, PlaceLatitudeValue, PlaceLongitudeValue, PlaceAddressValue, CategoryValue); return new Uri(NewURI, UriKind.Relative); } // Return a parsed Movie Card URI. private Uri GetMovieCardUri(string uri) { // Extract parameter values from URI. string MovieNameValue = GetURIParameterValue("MovieName=", uri); string CategoryValue = GetURIParameterValue("Category=", uri); // Create new URI. string NewURI = String.Format("/{0}?MovieName={1}&Category={2}", TargetPageName, MovieNameValue, CategoryValue); return new Uri(NewURI, UriKind.Relative); } // This method extracts the string values that correspond to parameters in an App Connect URI. private string GetURIParameterValue(string parameteridentifier, string uri) { string tempValue = ""; // If the parameter exists in the string, extract the corresonding parameter value. if (uri.Contains(parameteridentifier)) { string subUri; // Extract the characters that contain and follow the parameter identifier. subUri = uri.Substring(uri.LastIndexOf(parameteridentifier)); // Remove the parameter identifier from the substring. subUri = subUri.Replace(parameteridentifier, ""); // Obtain the position of the next parameter in the substring. int nextParameterPosition = FindNextParameter(subUri); if (nextParameterPosition < int.MaxValue) { // Remove the characters that contain and follow the next parameter. tempValue = subUri.Substring(0, nextParameterPosition); } else { // No more parameters follow in the string. tempValue = subUri; } // Encode the parameter values to help prevent issues in the URI. tempValue = HttpUtility.UrlEncode(tempValue); } return tempValue; } // Returns the string position of the next App Connect URI parameter, if applicable. private int FindNextParameter(string subUri) { int lowestPosition = int.MaxValue; int tempPosition; tempPosition = subUri.IndexOf("&ProductName"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; tempPosition = subUri.IndexOf("&Category"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; tempPosition = subUri.IndexOf("&PlaceName"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; tempPosition = subUri.IndexOf("?PlaceName"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; tempPosition = subUri.IndexOf("&PlaceLatitude"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; tempPosition = subUri.IndexOf("&PlaceLongitude"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; tempPosition = subUri.IndexOf("&PlaceAddress"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; tempPosition = subUri.IndexOf("&MovieName"); if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition; return lowestPosition; }
To Assign the URI-mapper to the Application Frame
-
In App.xaml.cs, add the following code to the InitializePhoneApplication method. Note that you may need to expand the code region titled “Phone application initialization” to locate the method.
// Assign the quick card URI-mapper class to the application frame. RootFrame.UriMapper = new QuickCardUriMapper();
This code assigns the QuickCardUriMapper class to the UriMapper property of the application frame. Do not modify any of the existing code in the InitializePhoneApplication method; only add the UriMapper-assignment, as shown in the following example.
private void InitializePhoneApplication() { if (phoneApplicationInitialized) return; // Create the frame but don't set it as RootVisual yet; this allows the splash // screen to remain active until the application is ready to render. RootFrame = new PhoneApplicationFrame(); RootFrame.Navigated += CompleteInitializePhoneApplication; // Assign the quick card URI-mapper class to the application frame. RootFrame.UriMapper = new QuickCardUriMapper(); // Handle navigation failures RootFrame.NavigationFailed += RootFrame_NavigationFailed; // Ensure we don't initialize again phoneApplicationInitialized = true; }
In this section you create a data model that represents a parameter from a quick card in the App Connect deep link URI. This class is used for binding to elements in the UI. For a full list of the parameters that correspond to each quick card, see Search Registration and Launch Reference for Windows Phone.
To create the data model
-
In Solution Explorer, right-click your project and select Add, then New Folder.
-
Name the new folder Model.
-
In Solution Explorer, right-click the Model folder and select Add, then New Item.
-
In the Add New Item window, select Code File and name the file AppConnectUriParameter.cs. Then click Add.
-
In AppConnectUriParameter.cs, add the following code.
using System.ComponentModel; namespace AppConnectExample.Model { // Represents a parameter from a quick card in an App Connect deep link URI public class AppConnectUriParameter : INotifyPropertyChanged { // The parameter name private string _paramName; public string ParamName { get {return _paramName;} set { if (_paramName != value) { _paramName = value; NotifyPropertyChanged("ParamName"); } } } // The parameter value private string _paramValue; public string ParamValue { get {return _paramValue;} set { if (_paramValue != value) { _paramValue = value; NotifyPropertyChanged("ParamValue"); } } } // Class constructor public AppConnectUriParameter(string pName, string pValue) { _paramName = pName.Trim(); if (_paramName == "Category") { // Place multiple categories on new lines. _paramValue = pValue.Replace(",",",\n"); } else { _paramValue = pValue; } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; // Used to notify that a property changed private void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } }
This class consists of properties for the parameter name and value, a constructor that accepts the name and value, and the INotifyPropertyChanged members.
In this section, you create the ViewModel that corresponds to the quick card target page, QuickCardTargetPage.xaml. The ViewModel is responsible for extracting the URI parameters from the App Connect deep link.
To create the ViewModel
-
In Solution Explorer, right-click your project and select Add, then New Folder.
-
Name the new folder ViewModel.
-
In Solution Explorer, right-click the ViewModel folder and select Add, then New Item.
-
In the Add New Item window, select Code File and name the file QuickCardTargetPageViewModel.cs. Then click Add.
-
In QuickCardTargetPageViewModel.cs, add the following code.
using System.ComponentModel; using System.Collections.ObjectModel; using System.Collections.Generic; // Reference the data model. using AppConnectExample.Model; namespace AppConnectExample.ViewModel { public class QuickCardTargetPageViewModel: INotifyPropertyChanged { // Observeable collection for the App Connect deep link URI parameters. private ObservableCollection<AppConnectUriParameter> _AppConnectUriParameters; public ObservableCollection<AppConnectUriParameter> AppConnectUriParameters { get {return _AppConnectUriParameters;} set { if (_AppConnectUriParameters != value) { _AppConnectUriParameters = value; NotifyPropertyChanged("AppConnectUriParameters"); } } } // Class constructor. public QuickCardTargetPageViewModel() { // Create observeable collection object. AppConnectUriParameters = new ObservableCollection<AppConnectUriParameter>(); } // Load parameters from quick page; extract from the NavigationContext.QueryString public void LoadUriParameters(IDictionary<string,string> QueryString) { // Clear parameters in the ViewModel. AppConnectUriParameters.Clear(); // Loop through the quick card parameters in the App Connect deep link URI. foreach (string strKey in QueryString.Keys) { // Set default value for parameter if no value is present. string strKeyValue = "<no value present in URI>"; // Try to extract parameter value from URI. QueryString.TryGetValue(strKey, out strKeyValue); // Add parameter object to ViewModel collection. AppConnectUriParameters.Add(new AppConnectUriParameter(strKey, strKeyValue)); } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; // Used to notify that a property has changed. private void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } }
In the LoadUriParameters method, the ViewModel extracts the parameters from the App Connect deep link URI and loads them into an observable collection of type AppConnectUriParameter.
In this section, you create the quick card target page. This is the page that is launched from a quick card via the App Connect deep link URI. With respect to the MVVM pattern, this page is the view.
To create the quick card target page
-
In Solution Explorer, right-click your project and select Add, then New Item.
-
In the Add New Item window, select Windows Phone Portrait Page and name the file QuickCardTargetPage.xaml. Then click Add.
-
In QuickCardTargetPage.xaml, replace the grid named LayoutRoot with the following code.
<!--LayoutRoot is the root grid where all page content is placed--> <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <!--TitlePanel contains the name of the application and page title--> <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> <TextBlock x:Name="ApplicationTitle" Text="QUICK CARD EXAMPLE" Style="{StaticResource PhoneTextNormalStyle}"/> <TextBlock x:Name="PageTitle" Text="URI details" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> </StackPanel> <!--ContentPanel contains ListBox and ListBox ItemTemplate.--> <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <ListBox x:Name="paramsListBox" Margin="0,0,-12,0" ItemsSource="{Binding AppConnectUriParameters}" > <ListBox.ItemTemplate> <DataTemplate> <StackPanel > <TextBlock Text="{Binding ParamName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/> <TextBlock Text="{Binding ParamValue}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextAccentStyle}"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> </Grid>In this page, a ListBox control is bound to observable collection in the ViewModel, named AppConnectUriParameters. Inside the ListBox, two TextBlock controls are bound to each parameter in the observable collection. One TextBlock control binds to the ParamName property, another TextBlock control binds to the ParamValue property.
-
In the code-behind file for the quick card target page, QuickCardTargetPage.xaml.cs, add the following directive to the top of the page.
-
In QuickCardTargetPage.xaml.cs, add the following code to the class constructor after the InitializeComponent() call.
// Create the ViewModel object. this.DataContext = new QuickCardTargetPageViewModel(); // Create event handler for the page Loaded event. this.Loaded += new RoutedEventHandler(QuickCardTargetPage_Loaded);This code creates a new QuickCardTargetPageViewModel object and assigns it to the data context of the page. This code also creates configures an event handler for the page Loaded event.
-
In QuickCardTargetPage.xaml.cs, add the following code to the page class.
// A property for the ViewModel. QuickCardTargetPageViewModel ViewModel { get { return (QuickCardTargetPageViewModel)DataContext; } } private void QuickCardTargetPage_Loaded(object sender, RoutedEventArgs e) { // Load the quick card parameters from the App Connect deep link URI. ViewModel.LoadUriParameters(this.NavigationContext.QueryString); }This creates a property for the ViewModel so that the LoadUriParameters method can be called. In the handler for the page Loaded event, the NavigationContext QueryString property is passed to the ViewModel so that the parameters can be extracted from the App Connect deep link URI.
In this section, you add text to the main page for a standard application launch.
To complete the application
-
In the main page of the application, MainPage.xaml, replace the grid named LayoutRoot with the following code.
<!--LayoutRoot is the root grid where all page content is placed--> <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <!--TitlePanel contains the name of the application and page title--> <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> <TextBlock x:Name="ApplicationTitle" Text="QUICK CARD EXAMPLE" Style="{StaticResource PhoneTextNormalStyle}"/> <TextBlock x:Name="PageTitle" Text="main page" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> </StackPanel> <!--ContentPanel - place additional content here--> <Grid x:Name="ContentPanel" Grid.Row="1" Margin="24,0,42,338"> <TextBlock Text="With App Connect, you can navigate directly to a relevant page in your app from a Bing quick card." TextWrapping="Wrap" Style="{StaticResource PhoneTextAccentStyle}" Margin="0,0,12,181" /> <TextBlock Text="To launch this app from a quick card, perform the testing steps outlined in the documentation." TextWrapping="Wrap" Style="{StaticResource PhoneTextAccentStyle}" Margin="0,94,0,83" /> </Grid> </Grid>This completes construction of the application.
This application is designed to help you explore live quick cards. In this section, you search for products, movies, and places that are associated with the extensions that were configured in the application manifest file. After locating a quick card, you launch your application to see the parameters that were passed to your application from the App Connect deep link URI.
Launching the application from a quick card breaks the debugging connection. To debug your application, follow the procedure named Debugging the Application.
Important Note:
|
|---|
|
Testing your application with quick cards requires an internet connect from your PC or Windows Phone device. |
To test with a product card
-
Press F5 to debug your application and deploy it to the emulator or device.
-
After the application loads, tap the hardware Search button to open Bing.
-
In Bing, enter a search term that is related to video game products, such as a video game console name. For example, “xbox 360” will return product cards related to Xbox 360 consoles. To test a product card with the Bing_Products_Video_Games extension, two things are required:
-
Bing must consider the search term relevant to video game products.
-
Product cards relevant to the search term must already exist at Bing and be associated with the Bing_Products_Video_Games extension.
-
-
On the web pivot page, select a product under the products heading. This will launch the quick card related to the product.
Tip:
If you do not see the products heading, try a different search term or add an additional product extension to the WMAppManifest.xml and Extras.xml files. For a complete list of search extensions, see Search Registration and Launch Reference for Windows Phone.
-
On the quick card for the product, swipe over to the apps pivot page and tap on the application titled Display URI Parameters. Note that the caption reads Product URI Details.
Note:
If you do not see an apps pivot page, the particular product card is not associated with the product extension listed in the WMAppManifest.xml and Extras.xml files. Tap the back button and try a different product card.
-
After tapping the application in the apps pivot page, observe that the QuickCardTargetPage.xaml page displays the parameters in the App Connect deep link URI for the product.
To test with a movie card
-
Press F5 to debug your application and deploy it to the emulator or device. This step is optional if you have already deployed the application.
-
After the application loads, tap the hardware Search button to open Bing.
-
In Bing, enter a search term that is related to movies that are currently in theaters, such as “movies”, “movies in theaters” or the name of a movie playing near you. To test a movie card with the Bing_Movies extension, two things are required:
-
Bing must consider the search term relevant to movies that are currently in theaters.
-
Movie cards relevant to the search term must already exist at Bing and be associated with the Bing_Movies extension.
-
-
On the web pivot page, select a movie listed in the search results above the web heading. This will launch the quick card related to the movie.
Note:
If you do not see movies listed above the web heading, try a different search term. There are no additional extensions available for movies.
-
On the quick card for the movie, swipe over to the apps pivot page and tap on the application titled Display URI Parameters. Note that the caption reads Movie URI Details.
-
After tapping the application in the apps pivot page, observe that the QuickCardTargetPage.xaml page displays the parameters in the App Connect deep link URI for the movie.
To test with a place card
-
Press F5 to debug your application and deploy it to the emulator or device.
-
After the application loads, tap the hardware Search button to open Bing.
-
In Bing, enter a search term that is related to food and dining, such as “food” or the name of a restaurant near you. To test a place card with the Bing_Places_Food_and_Dining extension, two things are required:
-
Bing must consider the search term relevant to a food and dining location.
-
Place cards relevant to the search term must already exist at Bing and be associated with the Bing_Places_Food_and_Dining extension.
-
-
On the local pivot page, select a food and dining location under the map that is displayed. This will launch the quick card related to the place.
Tip:
If you do not see results on the local pivot page, try a different search term or add an additional place extension to the WMAppManifest.xml and Extras.xml files. For a complete list of search extensions, see Search Registration and Launch Reference for Windows Phone.
-
On the quick card for the place, swipe over to the apps pivot page and tap on the application titled Display URI Parameters. Note that the caption reads Place URI Details.
Note:
If you do not see an apps pivot page, the particular place card is not associated with the place extension listed in the WMAppManifest.xml and Extras.xml files. Tap the back button and try a different place card.
-
After tapping the application in the apps pivot page, observe that the QuickCardTargetPage.xaml page displays the parameters in the App Connect deep link URI for the place.
The debugging process breaks when an application is relaunched from a quick card. To debug an App Connect launch to your application, you need to simulate a deep link URI. To do this, perform the following procedure to temporarily replace the DefaultTask element in the WPAppManifest.xml file.
To debug the application
-
In the application manifest file, WPAppManifest.xml, temporarily comment the original DefaultTask element.
Important Note:
Commenting out the original DefaultTask element prevents your application from performing a standard launch to the main page; it is important to uncomment this element when you are finished debugging.
-
In WPAppManifest.xml, add the following temporary DefaultTask element to the Tasks element.
<DefaultTask Name="_default" NavigationPage="SearchExtras?MovieName=Test&Category=Bing_Movies" />
This DefaultTask element simulates a movie card for a movie named “Test”.
-
Press F5 to debug your application and deploy it to the emulator or device.
-
Observe that the application launches directly to the QuickCardTargetPage.xaml page and displays the parameters in the App Connect deep link URI for a movie named Test.
-
In WPAppManifest.xml, comment out the temporary DefaultTask element and uncomment the original. When finished, the Tasks element should look like the following code.
<Tasks> <DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/> <!--<DefaultTask Name="_default" NavigationPage="SearchExtras?MovieName=Test&Category=Bing_Movies" />--> </Tasks>