Universal Store Apps - Mobile day by DotNetCampania

41
Universal Store Apps Emanuele Garofalo What’s new

Transcript of Universal Store Apps - Mobile day by DotNetCampania

Page 1: Universal Store Apps - Mobile day by DotNetCampania

Universal Store AppsEmanuele Garofalo

What’s new

Page 2: Universal Store Apps - Mobile day by DotNetCampania

Who am I?

Emanuele Garofalo

Page 3: Universal Store Apps - Mobile day by DotNetCampania

Agenda

Universal StoreApps

Page 4: Universal Store Apps - Mobile day by DotNetCampania

Perché?

Condivisioni a livello di piattaforma di sviluppo• API set • App model• Live Tiles • App distribution format• Controlli

Condivisioni a livello di servizi• Un solo store • Shared app identities + entitlement• Unified Push Services (WNS)• Unified App Data Roaming and backup

Page 5: Universal Store Apps - Mobile day by DotNetCampania

Perché?

Page 6: Universal Store Apps - Mobile day by DotNetCampania

Sembra entropia…ma non lo è

Serve a darti la…retro-compatibilità

Windows Phone Store App

Windows Store App

Windows Phone Silverlight (8.1) App

Page 7: Universal Store Apps - Mobile day by DotNetCampania

Facciamo chiarezza

Store Silverlight

People Hub

VoIP

Emulator, GeolocalizationGeofencing, Accessibility,

Roaming app data, A2A SSOShare contract, Background transfer

Push notification service Bluetooth LE, RFComm, WiFi Direct

NFC Secure Payment, Sensors,MMF (Microsoft Media Foundation),

Photo e Video Capture, AND MUCH MORE

Audio in Background

NuoviControlli XAML

Video editing API

Automated test tools

Alarm

Reminder

Lens App

Page 8: Universal Store Apps - Mobile day by DotNetCampania

Creiamo una universal app in visual studio

Page 9: Universal Store Apps - Mobile day by DotNetCampania

Il nuovo emulatore

Page 10: Universal Store Apps - Mobile day by DotNetCampania

Il nuovo emulatore

Page 11: Universal Store Apps - Mobile day by DotNetCampania

Il nuovo emulatore

Page 12: Universal Store Apps - Mobile day by DotNetCampania

Il nuovo emulatore

Page 13: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

ControlliApp life cycle

Manifest

BuildDeploy App model

Contratti

Page 14: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

• L’app viene sempre ripristinata (Resume)• Le app non si chiudono con il tasto back

• Le app vengono CHIUSE usanto l’app switcher

Page 15: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

Panorama Hub

LongListSelectorListView

+ Semantic zoom

• FlipView• GridView• ListView• RichEditBox• PasswordBox• SemanticZoom

Page 16: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

Comuni

Ottimizzati per la piattaforma

Specifici

TextBox

TextBlock

Button CheckBox

Date PickerTime Picker

Pivot (WP)

AppBar

Page 17: Universal Store Apps - Mobile day by DotNetCampania

Punti di convergenza – Controlli ottimizzati

Controlli

App life cycle

Manifest

Deploy

App model

<Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="20" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions>

<TimePicker/> <DatePicker Grid.Row="2" /></Grid>

Page 18: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

APPX for everyone (tranne che per Silverlight)

• In questo modo le risorse sono organizzate in bundle• Si riducono le dimensioni dei download• Non c’è molto da fare da parte nostra se usiamo le risorse

Page 19: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

Page 20: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

Page 21: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

Page 22: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

Page 23: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Deploy

App model

Page 24: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Build

Deploy

App model

Navigation Contracts Background

NavigationServiceFrame

// Simple navigation, no parameters Frame.Navigate(typeof(PaginaTarget));

// Passing a simple type, like an ID or an object Frame.Navigate(typeof(PaginaTarget), “21");

Rispetto alla navigazione basata su URI abbiamo il vantaggio di poter passare parametri di ogni tipo e non solo testuali

Page 25: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Build

Deploy

App model

Navigation Contracts Background

File Open Picker contract

File Save Picker contract

Share contract

And much more…

Page 26: Universal Store Apps - Mobile day by DotNetCampania

SHARE DALLA NOSTRA APPDemo

Page 27: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Build

Deploy

App model

Navigation Contracts Background

ScheduledTaskAgentWindows Runtime Background Tasks 

UserPresent , UserAway, SessionConnected, TimeZoneChange, NetworkStateChange, InternetAvailable, ServicingComplete, TimeTrigger, MaintenanceTrigger, GattCharacteristicNotificationTrigger, DeviceChangeTrigger, DeviceUpdateTrigger, RfcommConnectionTrigger, Geofencing

Page 28: Universal Store Apps - Mobile day by DotNetCampania

Novità – Punti di convergenza

Controlli

App life cycle

Manifest

Build

Deploy

App model

Navigation Packaging Contracts Background

Geocircle circle = new Geocircle(terminiCenter, radius: 26); Geofence geofence = new Geofence(“TerminiNikeStore", circle); GeofenceMonitor.Current.Geofences.Add(geofence);

//Registro il background TaskBackgroundTaskBuilder builder = 

new BackgroundTaskBuilder(); builder.SetTrigger(

new LocationTrigger(

LocationTriggerType.Geofence));

Page 29: Universal Store Apps - Mobile day by DotNetCampania

Novità – Windows Phone

Page 30: Universal Store Apps - Mobile day by DotNetCampania

Integrazione con il Notification Center

Cosa devo fare per integrarmi con il notification center?

(quasi) NIENTE!

Page 31: Universal Store Apps - Mobile day by DotNetCampania

Integrazione con il notification center

//Scegliete un templateToastTemplateType toastTemplate = ToastTemplateType.ToastText02;

//Recuperatene l’xmlXmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);

//trovate i tag textXmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");

//settate il valore dei tagtoastTextElements[0].AppendChild(toastXml.CreateTextNode(toastHeading));toastTextElements[1].AppendChild(toastXml.CreateTextNode(toastBody));

//scegliete la durata della notifica toastIXmlNode toastNode = toastXml.SelectSingleNode("/toast");((XmlElement)toastNode).SetAttribute("duration", "long");

//create la toast notificationToastNotification toast = new ToastNotification(toastXml);

//Mostrate la toast ToastNotificationManager.CreateToastNotifier().Show(toast);

Page 32: Universal Store Apps - Mobile day by DotNetCampania

Integrazione con il notification center

Per mostrare la notifica solo nel notification center:

toast.SuppressPopup = true;

NB: Se l’utente scegliesse di non mostrare le vostre notifiche sarebbe tutto (ovviamente) inutile

Page 33: Universal Store Apps - Mobile day by DotNetCampania

Integrazione con Cortana

Page 34: Universal Store Apps - Mobile day by DotNetCampania

Integrazione con CortanaOperazione in tre step

Creare il nostro file con la definizione dei

comandi vocali

Registrare i comandi vocali all’avvio

dell’applicazione

Gestire l’attivazione da comandi vocali

Page 35: Universal Store Apps - Mobile day by DotNetCampania

Comandi Vocali<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">

<CommandSet xml:lang="en-us" Name="englishCommands">

<CommandPrefix> MyApp </CommandPrefix> <Example> tweet 'welcome to mobileday' </Example>

<Command Name="Tweet"> <Example> tweet 'welcome to mobileday' </Example>

<!-- ListenFor elements provide ways to say the command, including references to {PhraseLists} and {PhraseTopics} as well as [optional] words --> <ListenFor> tweet </ListenFor> <ListenFor> tweet {dictatedSearchTerms} </ListenFor>

<Feedback> tweeting </Feedback>

<!-- Navigate specifies the desired page or invocation destination for the Command--> <Navigate Target="Tweet.xaml" /> </Command>

<PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject> twitter </Subject> </PhraseTopic>

</CommandSet></VoiceCommands>

Page 36: Universal Store Apps - Mobile day by DotNetCampania

Comandi Vocali

string voiceCommandName;

if (NavigationContext.QueryString.TryGetValue("voiceCommandName", out voiceCommandName)) { HandleVoiceCommand(voiceCommandName); } else { // If we just freshly launched this app without a Voice Command, asynchronously try to install the // Voice Commands. // If the commands are already installed, no action will be taken--there's no need to check. Task.Run(() => InstallVoiceCommands());

// Just for fun, we'll also animate the home page buttons FadeInfoButtons(true); }

Page 37: Universal Store Apps - Mobile day by DotNetCampania

Comandi Vocali

private async void InstallVoiceCommands() { try { bool using81orAbove = ((Environment.OSVersion.Version.Major >= 8) && (Environment.OSVersion.Version.Minor >= 10));

Uri vcdUri = new Uri("ms-appx:///VoiceCommandDefinition_8.1.xml");

await VoiceCommandService.InstallCommandSetsFromFileAsync(vcdUri); } catch (Exception ex) {

//Gestione dell’errore }

}

Page 38: Universal Store Apps - Mobile day by DotNetCampania

Comandi Vocali

void HandleVoiceCommand(string voiceCommandName){ string textToTweet = null; bool tweet = false;

switch (voiceCommandName) { case "Tweet": if (NavigationContext.QueryString.TryGetValue("naturalLanguage", out phraseTopicContents) && !String.IsNullOrEmpty(phraseTopicContents)) {

NavigationContext.QueryString.TryGetValue("dictatedSearchTerms", out textToTweet);

SendTweet(textToTweet); }

break;//…altri comandi…

} }

Page 39: Universal Store Apps - Mobile day by DotNetCampania

DA WINDOWS 8.1 A WINDOWS PHONE 8.1

Demo

Page 40: Universal Store Apps - Mobile day by DotNetCampania
Page 41: Universal Store Apps - Mobile day by DotNetCampania