共用方式為


Wallet for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

For more info about Windows Phone 8 capabilities, see App capabilities and hardware requirements for Windows Phone 8.

Registering as a Wallet extension

To increase the discoverability of your app that integrates with the Wallet, you can define your app as a Wallet extension. This makes your app appear in the other list of apps in the Wallet when the user taps add. The user can then pick your app from that list and the app will be downloaded and installed on the phone. This is another great way to increase the discoverability of your app.

To appear in the Wallet other list, register as one of the Wallet extensions. Extensions are specified in the WMAppManifest.xml file of your app project. The following is an example of a WMAppManifest.xml file that contains the Extension element to register the app as a Wallet extension.

<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="https://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
  <DefaultLanguage  code="en-US" />
  <App  ProductID="{3860f72b-b8fc-4503-b922-c25f315da9c3}" Title="SamplePhoneApp" RuntimeType="Silverlight" 
       Version="1.0.0.0" Genre="apps.normal" Author="PhoneApp2 author" Description="Sample description" Publisher="PhoneApp2" 
       PublisherID="{93da0024-839f-4d0a-a1af-414512aba376}">
    <IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
    <Capabilities>
      <Capability Name="ID_CAP_NETWORKING" />
      <Capability Name="ID_CAP_MEDIALIB_AUDIO" />
      <Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
      <Capability Name="ID_CAP_SENSORS" />
      <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
      <Capability Name="ID_CAP_WALLET" />
    </Capabilities>
    <Tasks>
      <DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
    </Tasks>
    <Tokens>
      <PrimaryToken TokenID="PhoneApp2Token" TaskName="_default">
        <TemplateIconic>
          <SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\IconicTileSmall.png</SmallImageURI>
          <Count>0</Count>
          <IconImageURI IsRelative="true" IsResource="false">Assets\Tiles\IconicTileMediumLarge.png</IconImageURI>
          <Title>SamplePhoneApp</Title>
          <Message>
          </Message>
          <BackgroundColor>
          </BackgroundColor>
          <HasLarge>false</HasLarge>
          <LargeContent1>
          </LargeContent1>
          <LargeContent2>
          </LargeContent2>
          <LargeContent3>
          </LargeContent3>
          <DeviceLockImageURI IsRelative="true" IsResource="false">
          </DeviceLockImageURI>
        </TemplateIconic>
      </PrimaryToken>
    </Tokens>
    <!--Register as a Wallet extension. The ConsumerID for Wallet extensions is always set to {5B04B775-356B-4AA0-AAF8-6491FFEA5683}, which is the id of the phone's Wallet app. -->
    <Extensions>
      <Extension ExtensionName="Wallet_app_membership" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5683}" TaskID="_default"/>
    </Extensions>
    <ScreenResolutions>
      <ScreenResolution Name="ID_RESOLUTION_WVGA" />
      <ScreenResolution Name="ID_RESOLUTION_WXGA" />
      <ScreenResolution Name="ID_RESOLUTION_HD720P" />
    </ScreenResolutions>
  </App>
</Deployment>

In the preceding code, the extension is defined by adding an Extension element to the Extensions section in the WMAppManifest.xml file. If the Extensions element is missing, you can add it after the Tokens section. The attributes for the entry are defined as follows.

  • ExtensionName: Defines the type of extension you are registering. Valid values for this attribute when registering as a Wallet extension are:

    • Wallet_app_other – for non-specific Wallet items

    • Wallet_app_loyalty – for loyalty cards

    • Wallet_app_membership – for membership cards

    • Wallet_app_transit – for transit cards

    • Wallet_app_payment – for payment cards

    You only need to register once, even if your app is used for multiple Wallet item types. You can register as an extension for multiple Wallet item types if you want by adding multiple Extension elements to the Extensions section in WMAppManifest.xml. Currently, when the user taps other to bring up the Add to Wallet dialog box and look for Wallet extensions, all extensions are returned, regardless of what Wallet item type was defined when registering as an extension.

  • ConsumerID: This is a fixed value, set to the id of the Wallet app on the phone, which is {5B04B775-356B-4AA0-AAF8-6491FFEA5683}. This is shown in the preceding code.

  • TaskID: Set this to default.

Registering as a Wallet extension is voluntary, but it is a great discoverability opportunity for your app. If you don’t register as an extension, your app won’t show up in the Add to Wallet dialog box. However, users can still search the Windows Phone Store and download your app as usual.

Note

Your app is not visible in the other list of apps in the Wallet until you have submitted it to the Store and it has been published. Your app is not visible in this list when testing with the Windows Phone 8 Emulator or a Windows Phone 8 device.

See Also

Other Resources

Wallet membership and deals sample

Wallet payments instruments sample

How to use the add Wallet item task for Windows Phone 8