Delen via


App contracts and extensions (Windows Runtime apps)

Apps use contracts and extensions to declare the interactions that they support with other apps. These apps must include required declarations in the package manifest and call required APIs to communicate with other contract participants.

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

For example, consider sharing information between two apps. The app that shares content out supports a source contract by meeting specific requirements, while the app that receives the shared content supports a target contract by meeting a different set of requirements. Neither app needs to know anything about the other. Every app that participates in the sharing contract can be confident that the sharing workflow is completely supported.

Extensions An extension is like an agreement between an app and the operating system. Extensions lets app developers extend or customize standard features primarily for use in their apps and potentially for use in other apps.

Use the package manifest to declare extensions. For example, an app can declare that it handles files with certain file extensions, or it can declare that it uses a particular dynamic-link library. In Microsoft Visual Studio, use the Declarations tab. If you are creating the package manually, see the Extensions element.

These next sections describe the various built-in app contracts and extensions.

Account picture provider (extension)

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.

For more info about this extension, see the UserInformation reference topic. You can also check out our Account picture name sample.

Alarm

An application can declare themselves as the System Alarm App. When a user goes through selection UI to set their System Alarm, only applications that are declared as System Alarm Apps can be selected. This behaves in a similar fashion to the Detailed Status slot on the PC Settings Page.

App service

Background tasks enable applications to communicate with each other and enable one application to call another. In order to use contracts to provide or launch these background tasks an application needs to be declared as an app service.

Appointments provider

Provides the capability for an application to interact with the calendar APIs and to create appointments.

AutoPlay (extension)

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 (extension)

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. For more info, see Supporting your app with background tasks and Introduction to Background Tasks.

The following types of background tasks are available through the Manifest Designer in Visual Studio.

Task type Applies to XAML HTML More info
Audio How to play audio in the background (Windows only), Overview: Background audio for Windows Phone
System event How to respond to system events with background tasks
Timer How to run a background task on a timer
Push notification Sending push notifications with WNS
Location Quickstart: Listening for geofence events in the background
Device use trigger Accessing sensors and devices from a background task
Control channel How to create a lock screen app that uses background network triggers
Chat message notification
Important  This type of background task is not available to all Windows Phone Store apps. Unless your developer account is specially provisioned by Microsoft, calls to these APIs will fail at runtime.
 

 

Update task (extension)

The Update task is a background task that is run directly after the user updates your app to a newer version. This gives your app the opportunity to perform configuration tasks, like setting up a push notification channel, without requiring the user to launch the updated app first.

For more info about this extension, see How to use the Update Task.

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 OneDrive can track a file to ensure that the user sees the latest version of the file and trigger updates to the file if the OneDrive app can provide a newer version. Additionally, if the user saves a newer version of a tracked file, OneDrive can trigger an update to its version of the file to ensure that OneDrive always has the newest version.

See Integrating with file picker contracts and Quickstart: Integrating with file picker contracts.

Camera settings (extension)

Device manufacturers can use a Windows Store device app to customize the flyout that displays more camera options. The More options flyout can appear with apps that use the CameraCaptureUI class to capture photos. For more info, see How to customize camera options (Windows Store device apps).

Dial protocol

If you are on a network device, you can use the DIAL protocol to launch applications on the Xbox One. If the application you are trying to run is not available, you can even use the DIAL network to install the application before running it.

File activation (extension)

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.

File Open Picker contract

You can help users pick files from your app directly while they are using 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 Integrating with file picker contracts.

File Save Picker contract

You can help users save files to your app directly while they are using another app. Users gain freedom and flexibility to save files to your app so they can quickly and easily access the file when they switch to your app.

Participating in this contract helps you increase the popularity and adoption of your app. For more info, see Integrating with file picker contracts.

Lock screen call

If a phone is locked, there is a limited amount of interaction that the user can perform. In some cases, a user would like to be able to answer a VoIP phone call without unlocking the phone. This contract makes that possible.

Media playback

Windows Store apps need to support this contract in order to indicate they support DVD playback.

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.

Preinstalled config task

Sometimes your application will need to update immediately after being installed. This contract will enable you to immediately launch an update task without any user interaction to make sure your application is updated immediately.

Manufacturers of 3D printers can provide a Windows Store device app to provide a unique experience in the 3D print dialog. If they do not, Windows provides a default 3D printing experience.

Device manufacturers can use a Windows Store device app to customize the flyout that displays advanced print settings. For more info, see How to customize print settings (Windows Store device apps).

URI activation (extension)

Your app can use existing URI schemes, such as mailto, or create a custom URI scheme. The URI activation extension enables you to define a custom URI scheme or register to handle an existing URI scheme.

See How to handle URI activation.

Restricted launch

Child app containers provide an extra level of isolation at runtime when untrusted content may be executed by the Windows Store app. This allows the app to protect itself from this untrusted content. For example, Microsoft Word might protect the user's resources from documents it is editing.

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 to an app.

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.

SSL/certificates (extension)

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.

Web account provider

Supporting single sign on (SSO) allows a user to sign on once and have that logging in action provide account information to multiple applications. This provides a richer experience through the other apps and also enables the convergence of multiple identities that support the SSO..