introducing windows runtime

59
Introducing Windows Runtime Hokuriku.NET vol.15 2014/8/30 Sat 遥遥遥 遥遥遥 遥遥

Upload: keefe-brady

Post on 02-Jan-2016

74 views

Category:

Documents


3 download

DESCRIPTION

Introducing Windows Runtime. Hokuriku.NET vol.15 2014/8/30 Sat 遥佐保(はるか・さお). はじめに. @ hr_sao. 本日 の 目的. Windows Runtime のファンを増やす! もっと 一緒 に勉強してくれる人が増えたらいいな …. Topics. Windows Runtime architecture Process Features Visual Studio Template Universal windows apps Windows store - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introducing Windows Runtime

Introducing Windows RuntimeHokuriku.NET vol.152014/8/30 Sat

遥佐保(はるか・さお)

Page 2: Introducing Windows Runtime

はじめに

Page 3: Introducing Windows Runtime

@hr_saoRoom metro Osaka

C++ テンプレート読書会

Microsoft MVP for Client App Dev[Jan,2010-Dec,2013]Microsoft MVP for Client Development [Jan,2014-Jun,2014]

Microsoft MVP for Windows Platform Development [Jul,2014-Dec,2014]

Page 4: Introducing Windows Runtime

Windows Runtime のファンを増やす!

もっと一緒に勉強してくれる人が増えたらいいな…

本日の目的

Page 5: Introducing Windows Runtime

1. Windows Runtime architecture

2. Process

3. Features

4. Visual Studio Template

5. Universal windows apps

6. Windows store

7. Add deployment

Topics

Page 6: Introducing Windows Runtime

1. Windows Runtime architecture

Page 7: Introducing Windows Runtime

Windows Runtime Technology Stacks

Windows SDKs

WinRT (native)

XAML-Windows8.1

DirectX / XAML-DirectX11.2

C/C++-C++11

CRT

HTML / CSS-Trident

C# / VB FCL JavaScript-Chakra

WinJS

描画

言語

VM CLR(native) Internet Explorer-WWAHost.exe

Win32 / COM

• Core• Controls• Data and content• Devices• Files and Folders

• Globalization• Graphics• Helpers• Media• Networking• Printing

• Presentation• Remote Desktop• Security• Social• UI Automation• User interaction

API

( 公開されている機

能 )

DesktopWindows Store

Apps

Page 8: Introducing Windows Runtime

Windows Store Apps から Win32/COM へは、原則呼び出し禁止

Windows Store Apps から呼び出しを許可されている COM はある  http://msdn.microsoft.com/en-us/library/br205753

Win32 and COM for Windows Store apps

Windows SDKs

Windows Runtime Win32 / COM

Desktop AppsWindows Store Apps

Page 9: Introducing Windows Runtime

Windows SDKs

Windows Runtime

Use Language

Windows Store Apps

C/C++-C++11

C# / VB JavaScript-Chakra

Page 10: Introducing Windows Runtime

全ての言語から利用できるための API とは?WinMD ファイル – metadata (ECMA-335)

• C:\Windows\System32\WinMetadata にある• .winmd 拡張子• 型やメンバが

記述されている

Windows MetaData

Page 11: Introducing Windows Runtime

メタデータを記載しているWindows Runtime の実体は EXE や DLLHKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId

WinMD <-> DLL

Page 12: Introducing Windows Runtime

Windows SDKs

Windows Runtime

Application Binary Interface

Windows Store Apps

C/C++ C# / VB JavaScript

Application Binary Interface

Windows Runtime は全て、 ABI を通じて API 提供を行う

Page 13: Introducing Windows Runtime

Windows SDKs

Windows Runtime

WinRT API projection - C#/VB

Windows Store Apps

Windows Runtime

WinMD

1. コンパイル時にWinMD を解析

C# / VB

2. 実行時、 CLR が WinMD を利用して WinRT API を呼び出す

1

2

CLR

Page 14: Introducing Windows Runtime

Windows SDKs

Windows Runtime

WinRT API projection - C++/CX

Windows Store Apps

C/C++

Windows Runtime

WinMD

1. コンパイル時に WinMD を解析2. 実行時 C++(native) から WinRT API を直接呼び

出す

1

2

Page 15: Introducing Windows Runtime

Windows SDKs

Windows Runtime

WinRT API projection - JavaScript

Windows Store Apps

Windows Runtime

WinMD

実行時、 IE(WWAHost.exe) が WinMD を解析しJavaScript から WinRT API を呼び出す

JavaScript

Internet Explorer-WWAHost.exe

Page 16: Introducing Windows Runtime

Windows SDKs

Windows Runtime

Windows Store Apps

C/C++ C# / VB JavaScript

Application Binary Interface

Windows Runtime と ABI のおかげで、各言語の相互利用が可能

Page 17: Introducing Windows Runtime

2. Process

Page 18: Introducing Windows Runtime

プロセスが Active 化するのは 2 パターン• メインビューのアクティブ化

Activation (1)

Page 19: Introducing Windows Runtime

Activation (2)• ホステッドビューのアクティブ化

例えば「共有」で出てくるやつ

Page 20: Introducing Windows Runtime

アクティブ化の方法は 2 つあるWindows ストアアプリのインスタンスは 1 つ - App オブジェクトはシングルトン

Initialization

Page 21: Introducing Windows Runtime

Process life time

アプリに終了の概念はなし待機時、バックグラウンドタスクを実行できる

Background task

Page 22: Introducing Windows Runtime

3. Features

Page 23: Introducing Windows Runtime

• パッケージデータ• ストレージ• ストリーム• ネットワーク• 通知• バックグラウンドタスク

Windows Runtime Features• 共有• 広告• アプリ内課金

Page 24: Introducing Windows Runtime

Package Data

Page 25: Introducing Windows Runtime

Windows::Storage::ApplicationData::Current

いわゆるセーブ領域• テンポラリ保存• ローカル保存• ローミングC:\Users\[ ユーザ名 ]\AppData\Local\Packages \[ パッケージファミリ名 ]\LocalState\_sessionState.dat

ApplicationData

Package.appxmanifest

Page 26: Introducing Windows Runtime

Notification

?

Page 27: Introducing Windows Runtime

Push Notification

Windows Push Notification Services

(1) ストアアプリの初回起動で  PushNotificationChannelManager   .CreatePushNotificationCahnellForApplicationAsync() を実行

(1) (2)

(2) Web サービスにチャネル URI (さっき (1) で取得したもの)を 送信する ※ 30 日で期限は切れる URI (例) https://xxx.notify.windows.com/?token=xxx

Page 28: Introducing Windows Runtime

Push Notification

Windows Push Notification Services

(3) 取得した URI(2) に、通知したいメッセージを付けて WNS に送信する  ※アプリ開発者だけが知っているクライアントシークレットを   付けて OAuth トークンを発行してもらう

(1)

(3)

(4) タイルの更新やトースト通知が実施される

(2)(4)

Page 29: Introducing Windows Runtime

Sharing data between apps

Page 30: Introducing Windows Runtime

クリップボードはシステムで 1 つだけstatic 実装されているWindows.ApplicationModel.DataTransfer.Clipboard

Sharing data - Clipboard

Page 31: Introducing Windows Runtime

←IE のリンクを受け取る FB アプリ

Shareing

共有ソースアプリ(共有するデータを持っている)

ターゲットアプリ(共有されたデータを受け取る)

Page 32: Introducing Windows Runtime

ソースアプリ( IE )で共有したいものをDataPackage に入れておく ※ターゲットアプリ( FB )と共有できるWindows.ApplicationModel.DataTransfer.DataPackage

Sharing data - DataPackage

共有チャームで共有

Page 33: Introducing Windows Runtime

Advertisement

Page 34: Introducing Windows Runtime

* Windows ストア アプリで収益を上げるには - http://www.microsoftvirtualacademy.com/training-courses/decode-track1

Page 35: Introducing Windows Runtime

Microsoft Advertising SDK のインストール - http://adsinapps.microsoft.com/ja-jp/sdk

Microsoft pubCenter に登録 - https://pubcenter.microsoft.com

Ad Control の貼り付け

Advertisement

Page 36: Introducing Windows Runtime

テスト用のコードが簡単に利用できる<UI:AdControl ApplicationId="d25517cb-12d4-4699-8bdc-52040c712cab“ AdUnitId="10043104" />

自分のやつはpubCenter で Get!

Ad control

Page 37: Introducing Windows Runtime

アプリ内課金Windows.ApplicationModel.Store

• アプリケーションのライセンスの状態を確認(評価版またはアクティブなライセンスなど)

• アプリ内機能の確認• アプリ内購入

Page 38: Introducing Windows Runtime

4. Visual Studio Template

Page 39: Introducing Windows Runtime

IPropertySet^ vals = ApplicationData::Current->LocalSettings->Values;if( vals->HasKey( "my_data” )){ vals->Remove( “my_data");}vals->Insert( "my_data", “Hokuriku" );

if( pageState->HasKey( "my_data” )){ pageState->Remove( “my_data" );}pageState->Insert( "my_data", “Hokuriku" );

Ex) ApplicationDataApplicationData を直接使う

VS テンプレートの NavigationHelper クラスの pageState を使う

Page 40: Introducing Windows Runtime

VS 付随のプロジェクトテンプレートがあるテンプレート固有話なのか? WinRT の話なのか?

Visual studio Template

Page 41: Introducing Windows Runtime

5. Universal windows apps

Page 42: Introducing Windows Runtime

• 1 つのソースで Windows ストアアプリとWindows Phone アプリの開発が出来る - ただし、 XAML は別

• どちらかのストアで購入すると、もう片方でも購入済みになる

• データが同期される* めとべや東京 #4 の資料公開。「ユニバーサル Windows アプリ入門」 # めとべや東京 - http://okazuki.hatenablog.com/entry/2014/05/31/153328

Page 43: Introducing Windows Runtime

これからプロジェクトを作るなら、ユニバーサルがおススメ

Windows Phone → Universal apps いばらの道

Windows store apps → Universal apps まぁ出来る

Universal apps → Windows store apps

WP 版を使わなければよい

Universal apps → Windows Phone ストア版を使わ

なければよい

Page 44: Introducing Windows Runtime

6. Windows store

Page 45: Introducing Windows Runtime

https://msdn.microsoft.com/ja-jp/windows/apps

Windows Developer Center

Page 46: Introducing Windows Runtime

ストアへのお布施(年単位)

Page 47: Introducing Windows Runtime

とにかく名前を登録する

プッシュ通知などに必要な情報はここでしか得られない(※企業用は別)

app for certification

Page 48: Introducing Windows Runtime

Live Services sitehttp://msdn.microsoft.com/ja-jp/library/windows/apps/xaml/hh868206.aspx

Page 49: Introducing Windows Runtime

単なる Azureの宣伝なので

無視

大事なのはここ!Live サービスサイ

アプリ内課金

Page 50: Introducing Windows Runtime
Page 51: Introducing Windows Runtime

7. App deployment

Page 52: Introducing Windows Runtime

「アプリをデプロイする」「配布する」とは?

→開発者が Windows ストアに 自分のアプリを登録すること

※その後、ユーザはアプリをクライアント PC に インストールする

Deployment …?

Page 53: Introducing Windows Runtime

(1) Visual Studio で開発し Visual Studio から実行• 開発者ライセンスを使って実行

- 無料ライセンス( 30~ 90 日程度で更新かな ? )

• もちろん VS 持ってないとダメ

How to Install (1/4)

Page 54: Introducing Windows Runtime

(2) Add-AppxPackage PowerShell コマンドを用いてインストールする• 開発者ライセンスを使って実行• パッケージの証明書入れる必要あり

( CertUtil.exe )• Add-AppxPackage でインストール* # めとべや 東京 2 で Sideloading Windows Store apps with PowerShell について発表してきました 資料公開http://tech.guitarrapc.com/entry/2013/10/15/073820

How to Install (2/4)

Page 55: Introducing Windows Runtime

(3) 企業内でサイドローディングして配布する• ActiveDirectory参加必須

- なので無印WindowsRT はだめ(企業向け)• エンタープライズサイドローディングキーを別途

購入する必要がある* WINDOWS ストア アプリのサイドローディングについてhttp://blogs.msdn.com/b/japan_platform_sdkwindows_sdk_support_team_blog/archive/2014/03/12/2014-03-12-windows.aspx

How to Install (3/4)

Open License, Select Plus で購入可能Windows 8.1 Enterprise Sideloading (10 Pack) と Windows 8.1 Enterprise Sideloading (100 Pack) があ

Page 56: Introducing Windows Runtime

(4) Windows ストアに出す!• マイクロソフトがアプリを事前にチェック• 合格したものだけをストアに出展• ストアに出すためにアプリ開発契約者(有料)に

なる必要がある• Windows ストアから Download & Instatll

How to Install (4/4)

Page 57: Introducing Windows Runtime

Fun…

Page 58: Introducing Windows Runtime

• クライアントで動作する Windows Runtimeの仕組みを知る

• Windows Runtime の固有機能を知る• その次に Visual Studio Template/Universal

windows apps

• Windows ストアの登録、配布、インストールも忘れずに

Let’s Windows Runtime

Page 59: Introducing Windows Runtime

プログラミングWindowsRuntime

参考