dotnet cologne 2015 - windows 10 appdev, teil2: coole apis - (daniel meixner)

40
NET

Upload: daniel-meixner

Post on 04-Aug-2015

41 views

Category:

Software


1 download

TRANSCRIPT

Page 1: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

NET

Page 2: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

XboxIoT

Page 3: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

App to AppCommunication

Page 4: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Today

- Share Contract

- File Picker

- Launch URI

Page 5: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Launcher.LaunchUriAsync(new Uri(“myapp:?Oh=yes“));

How Do I Link to an App?

http://aka.ms/launchwindowsapp

Page 6: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Custom schemes work on all platforms.

Spotify:// launches the Spotify app everywhere

Custom Schemes

Page 7: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

DEMO

Launch URI

Page 8: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Launcher.LaunchUriAsync

(new Uri(“myapp:?Oh=no“));

Evil Twin Problem

User/OS chooses target

Page 9: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Launch specific

var options = new LauncherOptions();

options.TargetApplicationPackageFamilyName= “12Me.MyApp";

Launcher.LaunchUriAsync(new Uri(“myapp:?Oh=yes"), options);

Page 10: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Get the PFN

private string GetPackageFamilyName()

{

return Windows.ApplicationModel.Package.Current.Id.FamilyName;

}

Page 11: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

var options = new LauncherOptions();

options.TargetApplicationPackageFamilyName= “12Me.MyApp";

string thumbnailToken = SharedStorageAccessManager.AddFile (gpxFile);

var launchUri = new Uri(“myapp:?Oh=yes&file=" + thumbnailToken);

await Launcher.LaunchUriAsync(launchUri, options, inputData);

Launcher.LaunchUriAsync(new Uri(“myapp:?Oh=yes"), options);

Page 12: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

//Query for a custom scheme (myapp)

var queryUri = new Uri(“myapp:");

await Launcher.QueryUriSupportAsync(queryUri, LaunchQuerySupportType.Uri);

//Query for a custom scheme supported by a specific app

var queryUri = new Uri(“myapp:");

string packageFamilyName = " 12Me.MyApp ";

await Launcher.QueryUriSupportAsync(queryUri, LaunchQuerySupportType.Uri, packageFamilyName);

Page 13: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

//Find all apps that support custom scheme myapp:

var customSchemeProviders = await Launcher.FindUriSchemeHandlersAsync(“myapp");

//Find all apps that can launch a file of type .foo

var fileTypeHandlers = await Launcher.FindFileTypeHandlersAsync(“.foo");

Page 14: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

//Find all apps that support custom scheme myapp:

var customSchemeProviders = await Launcher.FindUriSchemeHandlersAsync(“myapp");

//Find all apps that can launch a file of type .foo

var fileTypeHandlers = await Launcher.FindFileTypeHandlersAsync(“.foo");

Page 15: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

var resultData = new ValueSet();

resultData.Add("Result", value);

operation.ProtocolForResultsOperation.ReportCompleted(resultData);

App A App B

var options = new LauncherOptions();

options.TargetApplicationPackageFamilyName= “12Me.MyApp";

Launcher.LaunchUriForResultsAsync(new Uri(“myapp-forresults:?Oh=yes"), options);

Page 16: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

DEMO

Launch For Results

Page 17: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

App Services to AppCommunication

Page 18: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)
Page 19: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Client App A

Package with App Service

App Service

Background Taskvar conn = new AppServiceConnection();

conn.AppServiceName = “FooAppService”;

conn.PackageFamilyName = “12Me.MyApp“;

var status = await conn.OpenAsync();

Page 20: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Package with App Service

Client App A

App Service

Background Taskvar conn = new AppServiceConnection();

conn.AppServiceName = “FooAppService”;

conn.PackageFamilyName = “12Me.MyApp“;

var status = await conn.OpenAsync();

var message = new ValueSet();

message.Add(“Hi”, “There”);

var r = await conn.SendMessageAsync(message);

conn.Dispose();

Page 21: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Client App A

Client App B

Package with App Service

App Service

Background Task

App Service

Background TaskApp Service Connection

App Service Connection

Page 22: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Twitter

Facebook

People

Page 23: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

maps

maps

service

CacheExpose

Endpoint

Cortana

Page 24: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Band App

Provide

App service

Client App A

Client App B

Page 25: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Product Scanner

Checkout App

Inventory App

Inventory

Service

Payment Gateway

Page 26: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

DEMO

App Services

Page 27: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Enhanced App to App in Windows 10

Send file token, send data

Launch a *specific* app

App Services

Launch for Results

Shared App Folder

Page 28: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

1. Set breakpoints in app service code

2. Check ‘Do not launch but debug my code when it starts’ in project properties

3. Launch app service foreground app in debugger – nothing happens!

4. Run client app to connect to app service

5. Debugger attaches and breaks on your breakpoint

Debugging an App Service

Page 29: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Service is activated on-demand

Client may terminate service by disposing its AppServiceConnection

If the invoking app is suspended, app services sponsored by the app will be terminated

Insufficient resources may cause launch failure or service termination

App Service Lifetime

Page 30: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Wrap your custom scheme or app service in an SDK

Use NuGet to distribute SDK

Use REST-style versioning. For breaking changes, expose a new endpoint

Best Practices

Page 31: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Windows.System.LauncherLink to a specific app

Pass arbitrary data

Send files

Launch apps for results

Windows.ApplicationModel.AppServicesProvide services to other apps

Consume services provided by other apps

App to App Summary

Page 32: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Cortana

Office

Interactive Toasts

People/Contacts

Photos

Camera

Who’s Using these APIs?

Page 33: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Bluetooth Ads

Page 34: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Advertisement Watcher

Page 35: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Advertisement Publisher

Page 36: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

DEMO

BT Advertisment

Page 37: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

Trigger

Page 38: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

http://windows.Microsoft.com

Trigger based Background Tasks

Apps subscribe to triggers they are interested inOnly run *when* trigger is fired

• Push notification

• Geofencing

• BLE device

• Timer

• Sensors

Page 39: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

SystemTrigger

TimeTrigger

MaintenanceTrigger

DeviceUseTrigger

DeviceServicingTrigger

PushNotificationTrigger

CachedFileUpdaterTrigger

DeviceConnectionChangeTrigger

GattCharacteristicNotificationTrigger

RfcommConnectionTrigger

LocationTrigger

AppointmentStoreNotificationTrigger

ContactStoreNotificationTrigger

EmailStoreNotificationTrigger

BluetoothLEAdvertisementWatcherTrigger

BluetoothLEAdvertisementPublisherTrigger

DeviceWatcherTrigger

ActivitySensorTrigger

SensorDataThresholdTrigger

ToastNotificationHistoryChangedTrigger

ToastNotificationActionTrigger

ApplicationTrigger

MediaProcessingTrigger

SocketActivityTrigger

Triggers

Page 40: DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)

NET