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

Post on 24-Jan-2016

227 views 2 download

transcript

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

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

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

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

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.

codeSHOW

app at aka.ms/codeshowapp

codeshow.codeplex.com

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

installation of packages

requires Windows 8 and VS2012

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

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

Module Agenda

Create background tasks

Consume background tasks

Integrate WinRT components into a solution

˃

What is a background task?

Run code even if the app is not running

Features already available

Windows push notifications

Playback Manager for audio in background

Background transfer API for upload/download files

Share contracts

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

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

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();})();

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})();

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

package.appxmanifest - Declarations

Module Agenda

Create background tasks

Consume background tasks

Integrate WinRT components into a solution

˃

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.

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.

Triggers that require lock screen

Background task trigger type

Requires lock screen?

TimeTrigger YesPushNotificationTrigger YesControlChannelTrigger YesSystemTrigger* NoMaintenanceTrigger No

* SessionConnected, UserPresent, UserAway, and ControlChannelReset

BACKGROUND TASKS: CONSUMING

demo

Module Agenda

Create background tasks

Consume background tasks

Integrate WinRT components into a solution˃

What’s a component?JavaScriptC#

WinRTWinRT

Why components?

Performance

Modularity

Code reuse

Language preference

Language projections

C++

C#/VB

C++ C#/VB JS

WinRT

CODESHOW: COMPONENTS

demo

Summary

Create background tasks

Consume background tasks

Integrate WinRT components into a solution

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