42
Key technologies for shopping apps Santhosh Panchap & Can Comertoglu Microsoft Corporation 3-119

Web hosting in app Creating a Windows Store app with web assets

Embed Size (px)

Citation preview

Page 1: Web hosting in app Creating a Windows Store app with web assets

Key technologies for shopping apps

Santhosh Panchap & Can ComertogluMicrosoft Corporation3-119

Page 2: Web hosting in app Creating a Windows Store app with web assets

• Discuss and demonstrate specific features of shopping apps including• General architectural decisions• Optimizing virtualized result sets• The communication model

between web and app (auth, services)

• Payment methods• Other Windows features to

consider that enhance the shopping experience

• You’ll leave with • Knowledge and code to address unique

shopping app challenges

Agenda

Page 3: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

• Displaying and navigating large result sets• User authentication / secure credential storage• Payment• Sharing a wish list• User notification of “specials”• Printing receipts• App discoverability from website

Shopping app: key features

Page 4: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Web Services and component reuse reduces time to develop and

improves Site/App consistency.

Page 5: Web hosting in app Creating a Windows Store app with web assets

Web hosting in app Creating a Windows Store app with web assets

Model comparison

Page 6: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Website hosting : not a good design for feature rich apps• Webpages already have

commanding navigation and other Windows 8 built-in features

• Messages can be sent and received, but communication often requires changes to the website

• app ->web ->app• User interaction within the

webpage cannot be determined and must be constantly communicated through a callback, so the app can synchronize accordingly with the hosted content.

Commands Search Navigation Layout (vertical)

Page 7: Web hosting in app Creating a Windows Store app with web assets

Demo: using WebView (iFrame)

Page 8: Web hosting in app Creating a Windows Store app with web assets

Relevant code

Declaring the iFrame in XAML<WebView x:Name="webViewHost" Margin="189,113,0,0" Width="1030" HorizontalAlignment="Left" VerticalAlignment="Top" Height="503" Source="http://www.bing.com/shopping/search?q=windows&amp;FORM=L8SP10" />

Updating the source dynamicallywebViewHost.Source = new Uri("http://www.bing.com/rewards/tou");

Invoking script on the web pagewebViewHost.InvokeScript("CountAndListen", null);

Page 9: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

• Why native?• Great UI controls with built-in support for key Windows

UX experiences• Content first design • Unnecessary and confusing web navigation and commanding

chrome removed

• User model consistency• Brand integration into Windows

Store app model

Page 10: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Store app: utilizing web assets

• App UX guidelines are easily adhered to as the app is written specifically for the Windows experience

• Intrinsic controls provide touch first experiences

• App is focused on content, which is virtualized, fast, and fluid.

• The app communicates with Windows instead of app->web -> app->Windows -> app->web

• Web resources are retrieved via XHR against existing web services

Commands Search Navigation Layout (horizontal)

Page 11: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Recommendation

• Don’t use Webview or iFrame for primary experience

“The intent of WebView (iFrame) is to incorporate web content into an app context, and not to provide a browsing experience within the app. The Windows Store policy specifically disallows the latter, because such content won't generally go into snap view well, or necessarily respond to touch input consistently, thereby giving a sub-standard user experience.”

• Do use the standard app templates, Windows Controls and Commands, and Windows contracts such as Search, Share and Settings to create your experience.

Page 12: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

A great application experience provides for a content first, fast and responsive, fluid user experience.

Page 13: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Load, Store and display large sets of Data• Users generated search results often yield long lists• Keep the UI thread responsive : Use async• Use UI virtualization to create only visible items• Keep item templates simple• Load subsets• Model filtering appropriately

Page 14: Web hosting in app Creating a Windows Store app with web assets

Demo : List virtualization using web content

Page 15: Web hosting in app Creating a Windows Store app with web assets

Declarative template

<div data-win-control="SdkSample.ScenarioOutput"> <div id="itemTemplate" data-win-control="WinJS.Binding.Template"> <div class="itemTempl"> <img data-win-bind="src: thumbnail" alt="Databound image" /> <div class="content" data-win-bind="innerText: title"></div> </div> </div> <div id="listview1" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none', tapBehavior: 'none', swipeBehavior: 'none', layout: { type: WinJS.UI.GridLayout } }"> </div></div>

Page 16: Web hosting in app Creating a Windows Store app with web assets

Simple renderer

// wait for the itemPromise to complete to access the datareturn itemPromise.then(function (item) {

// root element for the itemvar element = document.createElement("div");element.className = "itemTempl";

// using innerHTML is usually faster than creating the DOM with createElement & appendChildelement.innerHTML = "<img src='" + item.data.thumbnail + "' alt='Databound image' /><div class='content'>" + item.data.title + "</div>";

return element;

Page 17: Web hosting in app Creating a Windows Store app with web assets

Function template with recycling

…// specifies a promise that will be completed when rendering is complete// itemPromise will complete when the data is availablerenderComplete: itemPromise.then(function (item) {

// mutate the element to include the dataif (!label) {

label = element.querySelector(".content");img = element.querySelector("img");

}

label.innerText = item.data.title;img.src = item.data.thumbnail;img.style.visibility = "visible";

Page 18: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

During authorization, user credentials must be secured.

Page 19: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Introducing the Web Authentication Broker

Page 20: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Web Authentication Broker

The Web Authentication Broker enables• Website hosting in an isolated

container within an app.• Secure user credential gathering

and authorization that is isolated from the app.

• Single sign-on with online providers (OAuth and OpenID).

Page 21: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Web Authentication Broker components

App container 1

Application

Medium

Runtime broker

App container 2

Web Auth Host

Page 22: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Web Authentication Broker flow

The broker takes down the dialog box, clears any persisted cookies created by the host from the app container, and returns the protocol data back to the application.

If a match is found, the host ends the navigation and signals the broker.

As the user interacts with the online provider website by clicking links or submitting information, the host checks each URI for a match with a callback URI provided by the

app before navigating to it.

The Web Auth host navigates to the request URI. (login page).

The broker starts the Web Auth Host and attaches it to the system modal dialog

The broker creates a system modal dialog and selects a separate, dedicated app container

An app invokes the Web AuthBroker async providing website and redirect URI

Page 23: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Page 24: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Page 25: Web hosting in app Creating a Windows Store app with web assets

Demo : PayPal

Page 26: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Windows provides features that significantly enhance the shopping

experience.

Page 27: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Live tiles are ambient notifications that draw users back to your app

Page 28: Web hosting in app Creating a Windows Store app with web assets

Demo : live tile update with web image

Page 29: Web hosting in app Creating a Windows Store app with web assets

Push Notification1. Request Channel URI.

2. Notification Client Platform asks WNS for a notification channel. WNS returns a Channel URI.

3. Channel URI provided to your App

4. Your App registers with your Cloud Service

5. Your Service notifies WNS by executing POST on Channel URI

6. WNS receives and routes notification to the appropriate device

Windows 8

NotificationClient Platform

AppCloud Service

Windows Push Notification Service

(4)

(5)

(6)

(1)(3)

(2)

Page 30: Web hosting in app Creating a Windows Store app with web assets

Sharing is a powerful way to increase engagement and

drive user acquisition.

Page 31: Web hosting in app Creating a Windows Store app with web assets

Demo : sharing

Page 32: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Sharing across Applications

Registers DataRequested

event handler with the Data Transfer

Manager

Receives event and fills DataPackage in

event handler

User selects “Share”, active app is sent

DataRequested event

Filters list of Target Apps and Quick Links

User selects Target App or Quick Link

Activate Target App as kind ShareTarget

Activated for Sharing

Process DataPackage

contents

Reports CompleteDataPackage lives in Source application

On installation, registers as Share Target through manifest declaration

Records QuickLink if Target App returned

one

Source App

Share Broker

Target App

Page 33: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Sharing details - source

// initializing codeDataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.DataRequested);

// registered functionprivate void DataRequested(DataTransferManager sender, DataRequestedEventArgs e){ DataRequest request = e.Request; { DataPackage requestData = String; request.Properties.Title = String; request.Properties.Description = String; // The description is optional. request.SetUri(Uri); } }

Page 34: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Sharing details - target

…if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.shareTarget) { // Code to handle activation goes here. } …

ShareOperation shareOperation = (ShareOperation)e.Parameter;await Task.Factory.StartNew(async () =>{

// Retrieve the data package properties.String sharedDataTitle = shareOperation.Data.Properties.Title;String sharedDataDescription = shareOperation.Data.Properties.Description;String sharedThumbnailStreamRef =

shareOperation.Data.Properties.Thumbnail;…}

Page 35: Web hosting in app Creating a Windows Store app with web assets

Printing

Page 36: Web hosting in app Creating a Windows Store app with web assets

Demo: printing

Page 37: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Printing

…// Add an event handler, which creates preview pages.

printDocument.Paginate += CreatePrintPreviewPages;

// Add an event handler, which provides a specified preview page. printDocument.GetPreviewPage += GetPrintPreviewPage;

// Add an event handler, which provides all final print pages. printDocument.AddPages += AddPrintPages;

// Create a PrintManager and add a handler for printing initialization. PrintManager printMan = PrintManager.GetForCurrentView();

printMan.PrintTaskRequested += PrintTaskRequested;

Page 38: Web hosting in app Creating a Windows Store app with web assets

• Consider your architecture carefully• Speed and responsiveness counts• Security is critical for your users and

your brand• Windows features bring your app to life!

Wrap up

Page 39: Web hosting in app Creating a Windows Store app with web assets

www.buildwindows.com

Related sessions

• “Guidance for shopping apps”. Speaker: Mark Hopkins

• “Shopping app case studies”. Speaker: Mark Hopkins

• “Deep Dive on WinJS ListView”. Speaker: Mike Mastrangelo

Page 40: Web hosting in app Creating a Windows Store app with web assets

Q&A

Page 42: Web hosting in app Creating a Windows Store app with web assets

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.