Presentation is loading. Please wait.

Presentation is loading. Please wait.

APLIKACIJE KOJE SU IZVAN SEBE Domagoj Pavlešić, dizzy.hr.

Similar presentations


Presentation on theme: "APLIKACIJE KOJE SU IZVAN SEBE Domagoj Pavlešić, dizzy.hr."— Presentation transcript:

1 APLIKACIJE KOJE SU IZVAN SEBE Domagoj Pavlešić, dizzy.hr

2

3 App to App in Windows 8.1

4 Launcher.LaunchUriAsync(new Uri("sampleapp:?ID=aea6")); Launcher.LaunchFileAsync(file); URI/Protocol Activation User/OS chooses target

5 Share Contract DataTransferManager.ShowShareUI(); User chooses target

6 App to App in Windows 10 UAP

7 Invoke a specific app URI Activation++ var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "24919.InstapaperIt"; var launchUri = new Uri("instapaper:?AddUrl=http%3A%2F%2Fbing.com"); await Launcher.LaunchUriAsync(launchUri, options);

8 Send Files URI Activation++ var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "24919.InstapaperIt"; var token = SharedStorageAccessManager.AddFile (gpxFile); ValueSet inputData = new ValueSet(); inputData.Add("Token", token); var launchUri = new Uri("instapaper:?AddUrl=http%3A%2F%2Fbing.com"); await Launcher.LaunchUriAsync(launchUri, options, inputData);

9 Discover if app already installed to handle a Uri Query URI Support var queryUri = new Uri("instapaper:"); await Launcher.QueryUriSupportAsync(queryUri, LaunchUriType.LaunchUri); ? var queryUri = new Uri("instapaper:"); string packageFamilyName = "24919.InstapaperIt"; await Launcher.QueryUriSupportAsync(queryUri, LaunchUriType.LaunchUriForResults, packageFamilyName);

10 Launching the app Launch for Results var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "24919.Instap"; var launchUri = new Uri("instapaper:?AddUrl=http%3A%2F%2Fbing.com"); await Launcher.LaunchUriForResultsAsync(launchUri, options, data); var resultData = new ValueSet(); resultData.Add("Result", value); operation.ProtocolForResultsOperation.ReportCompleted(resultData); App1App2

11 Apps from the same publisher share files and settings

12 A subfolder is required. Edit app manifest to add. Folders are automatically provisioned. Publisher’s shared storage folder

13 Access folder named “fonts” Windows.Storage.ApplicationData.Current.GetPublisherCacheFolder("fonts"); Clear shared storage Windows.Storage.ApplicationData.Current.ClearPublisherCacheFolderAsync(); Shared storage folder interaction

14 App Services Client App A Client App B Background Task App with App Service

15 Scenario: Bar Code Scanning Bar Code decoding App Service Image bytes in ValueSet or FileToken Decoded data

16 Scenario: Enterprise suite of apps App Service Maintains Inventory cache Client App A Client App B Interact with cloud services App Service Proximity Reading Services

17 DEMO

18 http://windows.Microsoft.com AppServiceConnection connection = new AppServiceConnection(); connection.AppServiceName = "microsoftDX-appservicesdemo"; connection.PackageFamilyName = "24919ArunjeetSingh.InstapaperIt"; AppServiceConnectionStatus connectionStatus = await connection.OpenAsync(); if (connectionStatus == AppServiceConnectionStatus.Success) { //Send data to the service var message = new ValueSet(); message.Add("Command", "CalcSum"); message.Add("Value1", Int32.Parse(Value1.Text)); message.Add("Value2", Int32.Parse(Value2.Text)); //Send message and wait for response AppServiceResponse response = await connection.SendMessageAsync(message); if (response.Status == AppServiceResponseStatus.Success) { int sum = (int)response.Message["Result"]; new MessageDialog("Result=" + sum).ShowAsync(); } } else { //Drive the user to store to install the app that provides the app service } App Services – Client

19 http://windows.Microsoft.com namespace AppServicesDemoTask { public sealed class AppServiceTask : IBackgroundTask { private static BackgroundTaskDeferral _serviceDeferral; public void Run(IBackgroundTaskInstance taskInstance) { // Associate a cancellation handler with the background task. taskInstance.Canceled += TaskInstance_Canceled; // Get the deferral object from the task instance _serviceDeferral = taskInstance.GetDeferral(); var appService = taskInstance.TriggerDetails as AppServiceTriggerDetails; if (appService.Name == "microsoftDX-appservicesdemo") { //Maybe ValidateCaller(appService.CallerPackageFamilyName) ?? appService.AppServiceConnection.RequestReceived += RequestReceived; } }... App Services – Service (1/2)

20 http://windows.Microsoft.com private async void RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { var message = args.Request.Message; // This service uses a Command keyed entry for the client to invoke services from the App Service string command = message["Command"] as string; switch (command) { case "DoIt": { var messageDeferral = args.GetDeferral(); int value1 = (int)message["Value1"];... Do some processing //Set a result to return to the caller var returnMessage = new ValueSet(); returnMessage.Add("Result", result); var responseStatus = await args.Request.SendResponseAsync(returnMessage); messageDeferral.Complete(); break; } case "Quit": { //Service was asked to quit. Complete service deferral so platform can terminate _serviceDeferral.Complete(); break; } } } App Services – Service (2/2)

21 http://windows.Microsoft.com Declaring App Service

22 http://windows.Microsoft.com Two-way Communication Client and server can keep a two-way chatty communication channel open Client can attach a RequestReceived event handler to its own AppServiceConnection instance Both client and server can send and receive messages AppServiceConnectionStatus connectionStatus = await connection.OpenAsync(); if (connectionStatus == AppServiceConnectionStatus.Success) { connection.RequestReceived += OnRequestReceived; }

23 http://windows.Microsoft.com Debugging Tips Getting the PackageFamilyName for the App Service Debugging your App Service

24 http://windows.Microsoft.com Getting the Service PackageFamilyName Later on, ‘Store – Associate App with the Store’ sets the correct PackageFamilyName In Tech Preview, Store not open yet for UAP Call Package.Current.Id.FamilyName to return PFN to use in debugging

25 http://windows.Microsoft.com Debugging App Services 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

26 Activated on-demand Terminted by app: – By disposing connection – By instruction service to shutdown – When client app is suspended Insufficient resources –AppServiceConnectionStatus.ResourcesNotAvailable –AppServiceResponseStatus.ResourceLimitsExceeded App Service Lifetime

27 App Services are designed to be flexible and light-weight and are modelled on web REST Web services –Simple Request-Response message API –Data packaged as string-keyed ValueSets –Easy to use with multiple different payloads When you publish an App Service, you are defining a communications endpoint –An App Service endpoint provides the Caller a way to send data to the Callee –An App Service endpoint also provides the Caller a way to request return values from the Callee and for the Callee to respond with these return values. What Protocol?

28 Build your own caller validation mechanisms on top of app services – Simplest is for service provider to whitelist callers based on their PackageFamilyName – PackageFamilyName of caller is passed with every request Possible to build more complicated caller validation mechanisms on top of ValueSets once a connection has been established – Whitelist could be followed by explicit X.509 certificate exchange Access restristion

29 No versioning REST API versioning model Breaking change demands new endpoint Versioning

30 URL/Protocol activation –specific app –send files –query Uri support –launch for results Shared Storage App Services App2app recap

31 Nagrađujemo vas sa 125 WinCoin bodova što ste posjetili predavanje. Osvojite dodatnih 150 WinCoin bodova ukoliko popunite službeni upitnik. HVALA!

32 Pitanja? domagoj@dizzy.hr @domagojpa domagoj.eu

33


Download ppt "APLIKACIJE KOJE SU IZVAN SEBE Domagoj Pavlešić, dizzy.hr."

Similar presentations


Ads by Google