Defining a data contract

Windows Store apps use contracts and extensions to declare the interactions that they support with other apps. These apps require declarations in the package manifest and call required Windows Runtime APIs to communicate with Windows and other contract participants.

A contract is an agreement between one or more apps. Contracts define the requirements that apps must meet to participate in these unique Windows interactions.

An extension is an agreement between an app and Windows 8. Extensions let app developers extend or customize standard Windows 8 features primarily for use in their apps and potentially for use in other apps.

For more information about data in Windows Store app built using HTML, see Sharing and exchanging data.

Types of contracts

Windows 8 supports the following built-in app contracts:

App to App Picking contract

You can help users pick files from one app directly from within another app. Users gain freedom and flexibility to choose files that are stored and presented by apps.

Participating in this contract helps you increase the popularity and adoption of your app. For more info, see Accessing files with file pickers.

Cached file updater contract

You can provide updates for particular files to help users who want to use your app as a central repository to track and maintain files. For example, Microsoft SkyDrive can track a file to ensure that the user sees the latest version of the file and trigger updates to the file if the SkyDrive app can provide a newer version. Additionally, if the user saves a newer version of a tracked file, SkyDrive can trigger an update to its version of the file to ensure that SkyDrive always has the newest version.

See Accessing files with file pickers and Providing file services from file pickers.

Play To contract

You can help your users play digital media to connected DLNA devices from within your app. Users tap the Connect charm and then the Play To button, confident that your app will play their media to the DLNA device.

Participating in this contract makes your app easy to use and encourages users to remain in your app for longer periods of time.

For more info, see Streaming media to devices using Play To.

Search contract

You can add a search pane to your app so users can search not only your app's content but content from other apps as well. Users can also transfer the search query itself to other apps. When you participate in this contract, you agree to make your app's content searchable by other participants and to present search results from those participants in your app.

Participating in this contract helps you gain traffic and usage for your app. For more info, see Adding search.

Settings contract

You can provide quick, in-context access to settings that affect the user's experience with your app.

Participating in this contract ensures that your app is consistent with the Windows settings model. For more info, see Adding app settings.

Share contract

You can help users share content from your app with another app or service, and vice versa. Participating in the Share contract means that you don't have to write extra code or provide other developers with an SDK for your app just to share content. Apps that support the Share contract can automatically share content to and from any other app that also supports the contract.

Participating in this contract helps you gain traffic and usage for your app. For more info, see Adding share.

Types of extensions

Windows 8 supports the following built-in app extensions:

Account picker

When users decide to change their account picture, they can either select an existing picture or use an app to take a new one. If your app can take pictures, you can use this extension to have Windows list your app in the Account Picture Settings control panel. From there, users can select it to create a new account picture.

AutoPlay

When the user connects a device to a computer, Windows fires an AutoPlay event. This extension enables your app to be listed as an AutoPlay choice for the one or more AutoPlay events.

For more info about this extension, see Auto-launching with AutoPlay.

Background tasks

Apps can use background tasks to run app code even when the app is suspended. Background tasks are intended for small work items that require no interaction with the user.

Camera settings

Your app can provide a custom user interface for selecting camera options and choosing effects when a camera is used to capture photos or video.

For more info about this extension, see Developing Windows Store device apps for cameras.

Contact picker

This extension enables your app to register to provide contact data. Your app is included in the list of apps that Windows displays whenever the user needs access to their contacts.

See Managing user contacts.

File activation

Files that have the same file name extension are of the same file type. Your app can use existing, well known file types, such as .txt, or create a new file type. The file activation extension enables you to define a new file type or register to handle a file type.

See How to handle file activation.

Game Explorer

Your app can register with Windows as a game. To do this, you must create a Game Definition File (GDF), build it as a binary resource in your app, and declare that resource in the package manifest.

When you provide a GDF file for your game, Windows can limit access to the game when the user has enabled family safety features.

For more info, see Creating a GDF file.

Print task settings

You can design an app that displays a custom print-related user interface and communicates directly with a print device. When you highlight the features that are specific to a particular make and model of print device, you can provide a richer, more enhanced user experience.

See Developing Windows Store device apps for printers.

Protocol activation

Your app can use existing protocols for communication, such as mailto, or create a custom protocol. The protocol activation extension enables you to define a custom protocol or register to handle an existing protocol.

See How to handle protocol activation.

SSL/certificates

Digital certificates are used to authenticate one entity to another. For example, certificates are often used to authenticate a user to web services over SSL. This extension enables you to install a digital certificate with your app.

See Encrypting data and working with certificates.