In Sharing from your app, we introduced the idea of sharing content from the example app Food with Friends to several target apps that let the user accomplish rich end-to-end scenarios. Apps in Windows 8 offer interesting content that your customers will want to share with friends or other apps. With a compelling and well-designed share target, your app can be at the heart of a social and connected experience for your customers.
In this post we look at how you can use the Share target contract for your apps, especially those like Food with Friends. Using this contract, your app can receive content from other apps and use that content to improve its quality. We want to help you make your app the best in its category!
A target app is built using the Share target contract and is designed for a quick and easy sharing experience. Not every app in Windows will be a share target, but if your app can publish, transform, store or somehow add value to content it receives from another app, there are benefits to creating a Share target.
- Your app will always show up in the target app list. It’s instantly relevant and connected to other apps that can share data you want.
- The share contract creates a bridge between your app and any source app without either app requiring one-to-one integration.
- Because the Share charm is always present and available in the OS, it gives your target app a presence in the OS that extends beyond the boundaries of your app. This can potentially point more customers to your app!
Receiving shared content
Let’s take a look at few examples that show how you can deliver compelling experiences through a Share target app.
You might already be familiar with the Mail and People apps on Windows 8. Mail creates an easy and personal share target experience for receiving and sharing content with one or more friends. The People app lets you share content with broader audiences on your social networks. In addition to social sharing, you can go a step further with in app-to-app sharing. Productivity apps like SkyDrive can receive files from anywhere in Windows and store these on the cloud; note-taking apps can receive text, links and possibly data in a wide variety of other formats and archive it for reference later. There’s also plenty of room to get creative.
Look at how the two pictures below show the share flow when sharing a photo from the Photos app to PuzzleTouch, a game app that turns the picture into a visual puzzle.
Figure 1: Source app on the left; list of filtered target apps that can receive photos in the Share pane on the right.
PuzzleTouch is one of the Share targets that can receive a picture from the Photos app.
Figure 2: On the right, the target app preview lets the user select what type of puzzle they
want to build. The puzzle is ready when the user switches back to the app.
What is a share target app?
An end-to-end sharing experience in Windows has two components. You have a source app that makes its content available in different formats to Windows. You also have a share target app that registers to recognize certain formats and act as the destination for the content being shared. Using the Share contract, the source app and the share target app communicate with each other.
When you think about the share experience for your app, consider that the share target app is rendered in the hosted Share window. Make sure you design the experience so your user can quickly preview their content and confirm sharing in this view. This example shows the Mail share target app view that allows a user to quickly share a link from the browser with one of his or her mail contacts.
Figure 3: Sharing a link from the Photos app using the Mail target app
Scenarios for Food with Friends
Now, let’s consider how Food with Friends creates a compelling Share target app experience. If you’re familiar with the app, you’ll see two main actions that a user can take in Food with Friends – creating a plan and adding a restaurant to their Wishlist. Of course, there are other actions such as writing a review, posting a comment, viewing your friends’ wish lists, and so on, but those experiences make sense within the context of the main app. For the two core scenarios that stand out, let’s do a quick sanity-check to see if these can be effectively completed via the Food with Friends target app.
Create Tonight’s plan
While a core scenario of the main app, this isn’t the best scenario for a Share target experience. Here’s why: The Share target experience is meant to be quick and easy. Creating a plan is a much more involved task – a user would want to know what other restaurants her friends want to try out, compare a few restaurants from their Wishlist, review ratings and so on. Because planning involves leveraging details that are best presented in the main app view, condensing that functionality into the Share target app is not compelling.
Add to Wishlist
This scenario works really well as a short and directed task in the Share target. Some highlights in this app experience:
- People come across restaurants in other apps, whether these are trip planning apps, local city apps with recommendations, food blogs, and so on. Food with Friends is a great destination for aggregating restaurants in the ‘My Wishlist’ section.
- The target app view of an app is designed for a user to quickly take action while in the context of a different app. Thus, adding a restaurant to a Wishlist is an excellent option to surface in the Share target.
- While it’s certainly possible for the user to switch apps, repeat the search to find the restaurant, and then add the restaurant to their Wishlist, it’s a much easier experience to quick tap on Share.
The Food with Friends Wishlist seems to be a great share target app experience that we want to design and build. Here’s the end-to-end scenario we have in mind:
While browsing an app that shows me local food trucks, I find a food truck recommendation that sounds interesting. I want to add the food truck from this app to My Wishlist in Food with Friends to help with planning later.
This image shows the share target app view that we want to use:
Figure 5: The share target app view
By completing the share action in the target app view, users can curate restaurants in Food with Friends, without switching context from their current immersive app experience.
Implementing a share target
Now that you’ve seen some examples of when to implement a share target, let’s look at how you implement a share target. First, decide which data formats your app can receive.
Which data formats should you support?
With Share you can support either standard data formats such as text, URI, HTML, bitmaps, files or custom data formats such as the ones listed on http://schema.org . Windows filters target apps by the data formats they support to display the filtered target app list in the Share pane. Your app should support data formats that are important to the app experience. For example, if your app is about viewing photos, supporting text formats might not be helpful. If you declare support for multiple data formats, decide which one helps you represent the shared data best so you can pick that format from the data package first.
Since Food with Friends is implementing a share target experience that lets users share restaurants to the app, we’ll use the Restaurant data format listed on http://schema.org. Food with Friends can register with the Share target contract to receive this data format. Then, using the data in the received package, it can build a compelling experience in its target app view that allows the user to add that restaurant to their Wishlist.
While some source apps may specifically share out the Restaurant data format, other source apps may represent similar information using other data formats like Place, LocalBusiness and FoodEstablishment listed on schema.org. Thus, Food with Friends can support receiving multiple formats in the share contract to cater to a wider variety of source apps.
Food with Friends supports the following formats in the Share target declarations of the app manifest:
We’re focusing on the Restaurant data type for the sake of brevity, but the concepts apply to other data types as well.
Which data formats and scenarios should you scope out?
Food with Friends will only support adding the restaurant to the user’s Wishlist if the restaurant information received matches that of a restaurant that the app is already aware of. This is intentional to avoid multiple copies of restaurants in the app.
We’re not supporting standard data types because most text, files, photos, URI or HTML shared from source apps won’t be mapped to a restaurant or local business. For example, if Food with Friends supported receiving text, it would show up in the target app list for a notetaking source app. In this case, Food With Friends would need to provide an error message telling the user why this app doesn’t work with their source app. Bottom line, the data formats are what connect a source app that has something to offer a target app. If the data formats aren’t the same, there’s nothing worthwhile to share.
Make sure you consider all data formats that help identify what you care about, scope out the data formats that dilute your share experience.
Supporting the Share target contract
To support data formats, declare them in the Visual Studio manifest designer for your app. This is what happens when a user selects your app as the target of a share action:
- A new instance of the app is launched in the share target window over the source app.
- A share target activation event is fired and your app receives a ShareOperation object as a result.
- Your app can retrieve the data that the user shared from this object.
- You can use this data to render the target app view and complete the user’s share.
Additionally, Visual Studio supports a template for share targets. Right-click your project, select Add Item, Add New Item, click Share Target Contract from the list and you get code added for supporting the contract. The Share target code sample shows how to receive shared content.
Designing a tailored target app view
When the user selects a target app from the list of apps in the Share pane, Windows launches the app in the app’s share target view. The target app view is a special view hosted in the Share pane and is different from the app’s main view. Activating Windows 8 contracts in your app gives more info about hosted views and handling activation for these views. The target app view is designed to help complete the share action initiated by the user. In this view, users should be able to preview their content at a glance, take simple actions, and confirm their intent to share.
Before we look at the target app design for Food with Friends, let’s consider a target app that you might already know. The images below show the target app view for the Mail app alongside the full view of the app in Windows 8.
Figure 6: Sharing from Photos to the Mail target app on the right
Figure 7: Composing a new mail in the main app view of Mail
Notice that Mail’s share target app view is simpler than its full app view. It provides a clean and minimal preview of the content the user is about to share in the form of a thumbnail and associated text and HTML. It provides a To line for adding recipients, an input area for composing a quick message and an easy to way to confirm sending the mail through the Send button.
Despite this simpler view, the app’s target app view is clearly identifiable as an avatar of the Mail app, which reinforces user confidence about the destination of the shared content.
Food with Friends as a share target app
Now that you have a general idea about design for the target app view, let’s discuss how Food with Friends can create a target app helps users add restaurants to the ‘My Wishlist.’
When Food with Friends receives the data package containing a Restaurant from the source app, it can use the details in the Restaurant data format to identify which restaurant from its existing database matches the received data package. The app can then show a preview of this restaurant in the target app view. This reinforces confidence in the integrity of the content being shared.
This image shows the target app view for Food with Friends –
As you can see this view of Food with Friends is simple and tailored for a share target app - It shows a preview of the restaurant that the user is about to share and a simple actionable button, Add to Wishlist that clarifies the destination of the shared content in the main app. When the user taps or clicks this button, it confirms the share operation. By requiring a tap or click here, we help prevent accidental sharing and build confidence in the overall Share experience.
If the app finds multiple restaurants that match the info of the data package content, Food with Friends uses the share target app view to show the options and let the user pick which ones to share.
Figure 9: Target app view shows options so users can pick which items to share
In case the app cannot accurately identify a restaurant or a valid set of options based on the received data package, use the target app view to communicate that message.
Creating a QuickLink
A QuickLink is a provision of the Share API that lets users share content to familiar destinations within your target app quickly. A QuickLink acts as a customized link to your target view, providing specific actions. When Windows filters the list of target apps available to the user, the list of QuickLinks is featured at the top of the Share pane as the list of available targets. These familiar destinations or user actions may include places or people that are shared with often through the target app. For example, the Mail app returns QuickLinks for previously mailed contacts. Similarly, you can add QuickLinks to folders, groups, notebooks, and playlists that you share often to your target app.
Figure 10: Share pane shows a QuickLink provided by the Mail target app for contacts
that have been previously mailed using the target app
The target app can provide a QuickLink by calling ShareOperation objects’ reportCompleted method. A QuickLink must have a title, an icon, and an ID. The title (like "Email Mom") and icon appear when the user taps the Share charm. The ID is what your app uses to access any custom information, such as an email address, a folder location and so on. See How to Create a QuickLink to learn more about this tool.
Note: QuickLinks are useful when the app supports multiple actions from the target app. Because Food with Friends only supports a single action in the Share target i.e. Add to Wishlist, the app doesn’t implement QuickLinks.
Extended share and error reporting
Sometimes source apps share large chunks of data like photos, videos, or files resulting in longer data transfer times. These types of share operations are known as extended shares where your target app might need more time to receive and process the data.
Because sharing is to be fast and fluid and the target app view is a lightweight, hosted view over the main app, users might tap away from the target app view to get back to their main app. Thus, target apps shouldn’t rely on or expect user interaction with the target app view after sharing has begun. Target apps can rely on using the ShareOperation object and its methods to let Windows know that the app is processing data.
- reportStarted – call this method to let Windows know your app has started retrieving the data in the DataPackage object from the source app.
- reportDataRetrieved – call this method to let Windows know your app has finished retrieving the data in the package.
- reportCompleted – call this method to let Windows know your app has completed the Share operation.
When your app is processing data for an extended share, give the user a progress UI in the target app view. This informs the user that their request is underway and reinforces confidence when they return to your app and check on the progress of the share operation. Check out Quickstart: adding progress controls to learn more about progress controls in Windows 8.
Figure 11: Mail target app view shows a progress ring when completing an extended share such as sending over large attachments
If something goes wrong during the data transfer and your target app has to end the share operation, you can call reportError to send an error message to Windows. The user will see the message when they check status of the share in the Share pane. After you report the error, your app is shut down and the share is ended. The user will need to start again to share the content to your app.
In the Food with Friends share target example, if the app cannot identify a restaurant in its database that matches the restaurant that was shared from the source app via the Restaurant data format, the app should report an error.
App-to-app sharing provides a great opportunity to share target apps. By enabling your app to receive shared content, your users get value from your app even when they are involved in another activity. We hope you have a better understanding of the design principles as well data types, classes and properties that you can use to create a great share target destination. We’re excited to discover how your apps will transform shared content and create broader and richer end-user experiences.
Windows User Experience