advanced windows 8 apps using javascript jump start 70-482 exam prep advanced windows 8 apps using...

29
Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist Michael Palermo Microsoft Technical Evangelist

Upload: gabriel-booth

Post on 24-Jan-2016

228 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep

Advanced Windows 8 AppsUsing JavaScript

Jeremy FosterMicrosoft Developer Evangelist

Michael PalermoMicrosoft Technical Evangelist

Page 2: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Meet Jeremy Foster | @codefoster

• Microsoft Technical Evangelist– Industry experience in education, aerospace

manufacturing, insurance

• Passion for informing and inspiring software developers to write code and to “write it right”– www.codefoster.com– codeshow.codeplex.com– aka.ms/cssbook

Page 3: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Meet Michael Palermo | @palermo4

• Microsoft Technical Evangelist– Prior to Microsoft, served as a Microsoft Regional Director,

MVP, and Microsoft “insider” on a wide variety of technologies

• Passion for HTML, CSS, JavaScript, and all things Windows 8– http://aka.ms/palermo4– http://aka.ms/70-482

Page 4: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Accelerated Certification Prep Jump Start

Fast-paced, real-world scenario approach

No hands-on labs provided

Download demo code from codeshow.codeplex.com

Download the Windows 8 app at aka.ms/codeshowapp

Page 5: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Jump Start Target Agenda

Advanced Windows 8 Apps Using JavaScript (Exam 70-482 prep)

Module 1: Background Tasks and ComponentsCreating and consuming background tasks and components to make your code more reusable

Module 2: Hardware and SensorsCapturing media from the camera and microphone, discovering what the device is capable of, and reading from the various hardware sensors.

Module 3: Printing and PlayToImplementing the printing and PlayTo contracts and understanding the push notification system for doing live tile updates and more.

MEAL BREAK

Module 4: Animations, Custom Controls, and GlobalizationFacilitating good UI responsiveness for a fast and fluid experience, implementing animations and transitions, creating custom WinJS controls, and building in globalization/localization for broader reach.

Module 5: Data, Files, and EncryptionDesigning and implementing data caching, saving and retrieving files from the file system, and securing application data.

Module 6: DeploymentAdding trial functionality, handling errors, implementing a test strategy, and designing a diagnostic and monitoring strategy.

Page 6: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

codeSHOW

app at aka.ms/codeshowapp

codeshow.codeplex.com

git clone https://git01.codeplex.com/codeshow

installation of packages

requires Windows 8 and VS2012

Page 7: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep

M1: Background Tasks and Components

Jeremy FosterMicrosoft Developer Evangelist

Michael PalermoMicrosoft Technical Evangelist

Page 8: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Jump Start Target Agenda

Advanced Windows 8 Apps Using JavaScript

Module 1: Background Tasks and Components

Module 2: Hardware and Sensors

Module 3: Printing and PlayTo

MEAL BREAK

Module 4: Animations, Custom Controls, and Globalization

Module 5: Data, Files, and Encryption

Module 6: Deployment

Page 9: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Module Agenda

Create background tasks

Consume background tasks

Integrate WinRT components into a solution

˃

Page 10: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

What is a background task?

Run code even if the app is not running

Page 11: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Features already available

Windows push notifications

Playback Manager for audio in background

Background transfer API for upload/download files

Share contracts

Page 12: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Appropriate scenarios for background task?

Downloading new content for app (such as mail)

Show toast notification (such as a chat request)

Updating service with change (such as user present)

Not appropriate?

Exhaustive work-loads

Anything requiring user interaction

Page 13: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

How to create a background task

Create a javascript worker file

Implement task behaviors in worker file

Register background task

Declare background task in application manifest

Page 14: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

task.js // this file runs in context of WorkerGlobalScope(function () {

// importScripts is method of WorkerGlobalScope importScripts( “//Microsoft.WinJS.1.0/js/base.js”, “/js/app.js” );

// do work here, possibly using code from /js/app.js

// close is a method of WorkerGlobalScope close();})();

Page 15: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

WebUIBackgroundTaskInstance(function () { // imports

// access background task via current property var currentTask = WebUIBackgroundTaskInstance.current; // instanceId, progress, succeeded // getDeferral for async calls within task // canceled event handler

// close})();

Page 16: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

BackgroundTaskBuilder// create “namespace”var back = Windows.ApplicationModel.Background; // create instance of BackgroundTaskBuildervar builder = back.BackgroundTaskBuilder();builder.name = “task name”;builder.taskEntryPoint = “js\\task.js”;builder.setTrigger(new back.TimeTrigger(15, false));

// register the taskbuilder.register();

Page 17: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

package.appxmanifest - Declarations

Page 18: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Module Agenda

Create background tasks

Consume background tasks

Integrate WinRT components into a solution

˃

Page 19: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

How tasks are triggeredTrigger type Trigger event Trigger event detailsControlChannelTrigger ControlChannelTrigger On incoming messages on the control channel. MaintenanceTrigger MaintenanceTrigger It’s time for maintenance background tasks. PushNotificationTrigger

PushNotificationTrigger A raw notification arrives on the WNS channel.

SystemEventTrigger InternetAvailable The Internet becomes available.SystemEventTrigger LockScreenApplicationAdded An app tile is added to the lock screen.SystemEventTrigger LockScreenApplicationRemoved An app tile is removed from the lock screen.SystemEventTrigger ControlChannelReset A network channel is reset. SystemEventTrigger NetworkStateChange A network change such as a change in cost or connectivity occurs. SystemEventTrigger OnlineIdConnectedStateChange Online ID associated with the account changes. SystemEventTrigger ServicingComplete The system has finished updating an application.SystemEventTrigger SessionConnected The session is connected.SystemEventTrigger SessionDisconnected The session is disconnected.SystemEventTrigger SmsReceived A new SMS message is received by an installed mobile broadband device.SystemEventTrigger TimeZoneChange The time zone changes on the device (for example, when the system adjusts the clock for daylight

saving time).SystemEventTrigger UserAway The user becomes absent.SystemEventTrigger UserPresent The user becomes present.TimeTrigger TimeTrigger A time event occurs.

Page 20: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Tasks can have conditions

Background task condition The condition that must be satisfied

InternetAvailable The Internet must be available.InternetNotAvailable The Internet must be unavailable.SessionConnected The session must be connected.SessionDisconnected The session must be disconnected.UserNotPresent The user must be away.UserPresent The user must be present.

Page 21: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Triggers that require lock screen

Background task trigger type

Requires lock screen?

TimeTrigger YesPushNotificationTrigger YesControlChannelTrigger YesSystemTrigger* NoMaintenanceTrigger No

* SessionConnected, UserPresent, UserAway, and ControlChannelReset

Page 22: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

BACKGROUND TASKS: CONSUMING

demo

Page 23: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Module Agenda

Create background tasks

Consume background tasks

Integrate WinRT components into a solution˃

Page 24: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

What’s a component?JavaScriptC#

WinRTWinRT

Page 25: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Why components?

Performance

Modularity

Code reuse

Language preference

Page 26: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Language projections

C++

C#/VB

C++ C#/VB JS

WinRT

Page 27: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

CODESHOW: COMPONENTS

demo

Page 28: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

Summary

Create background tasks

Consume background tasks

Integrate WinRT components into a solution

Page 29: Advanced Windows 8 Apps Using JavaScript Jump Start 70-482 Exam Prep Advanced Windows 8 Apps Using JavaScript Jeremy Foster Microsoft Developer Evangelist

© 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.

© 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.