27
@ @ Live Tile, Background Agent e Push Notification Luca Cestola [email protected] @lucacestola

Push Notification, Live Tile e Background Agent

Embed Size (px)

DESCRIPTION

Sessione"Push Notification, Live Tile e Background Agent" tenuta da Luca Cestola all'evento Win8@Work di DomusDotNet

Citation preview

Page 1: Push Notification, Live Tile e Background Agent

@@Live Tile, Background Agent e Push Notification

Luca [email protected]

@lucacestola

Page 2: Push Notification, Live Tile e Background Agent

@Con Windows 8 la nostra applicazione ha diversi modi per comunicare attivamente informazioni all’utente.Dove?• Start screen• Lock screenCome?• Tiles• Toast• Badge

Un approccio differente

Page 3: Push Notification, Live Tile e Background Agent

@Start screen• È dove risiedono le Tiles delle applicazioni.• Si può organizzare la posizione e la grandezza

delle Tiles e decidere quali includere o escludere.

• Veicola informazioni che hanno a che fare con le nostre applicazioni

Lock screen• In maniera ridotta, offre comunque la possibilità

alle nostre applicazioni di comunicare con l’utente alcune informazioni utili.

Start screen e Lock screen

Page 4: Push Notification, Live Tile e Background Agent

@Tiles: cos’è?

“Una tile è la rappresentazione di una app sullo start screen” Rappresenta un punto di ingresso alla nostra applicazione, ma è anche veicolo attivo di informazioni verso l’utente.

• Principale o secondaria• Due grandezze: Square o Wide• Se esistono entrambe, l’utente può scegliere

quale grandezza visualizzare.

• Zero o più tile secondarie• Ogni tile secondaria può offrire un diverso

contenuto e punto di ingresso all’applicazione

Page 5: Push Notification, Live Tile e Background Agent

@Live Tiles: perché?

Investire del tempo nelle Live Tiles perché:• Rappresentano un elemento distintivo

per la nostra app.• Posizionamento migliore sullo Start

Screen• Una Live Tile è più accattivante (ed utile)

di una statica• Se l’aspetto non è accattivante e le

informazioni non sono utili l’utente la Tile verrà posizionata in fondo allo Start Screen

Page 6: Push Notification, Live Tile e Background Agent

@Elementi grafici della tile

Template

Brand grafico o testuale

Badge(Numeric o Glyph)

Page 7: Push Notification, Live Tile e Background Agent

@Live Tiles: perché?

Caratteristiche da tenere in considerazione:• Non è solo una questione di

«gradevolezza»• Contenuti nuovi e frequenti comunicano

che la nostra applicazione è «viva»• Informazioni personalizzate tramite ciò

che conosciamo dell’utente (app settings o info presenti sui social)

• Informazioni contestualizzate (ad esempio localizzazione GPS)

Page 8: Push Notification, Live Tile e Background Agent

@Aspetto grafico: Dimensioni

Le tiles possono avere aspetti grafici differenti. Si devono utilizzare i template predefiniti.

• Square Tile• Contenuti e testo ridotti• Possono contenere un

badge e un glyph o un numero

• Wide Tile• Più spazio e di conseguenza

più immagini o testo

Page 9: Push Notification, Live Tile e Background Agent

@Aspetto grafico: Coerenza

Page 10: Push Notification, Live Tile e Background Agent

@Aspetto grafico: Errori da evitare

Il brand o il nome dell’applicazione hanno un loro apposito posizionamento, evitate di ripetere tali informazioni in altre posizioni

Page 12: Push Notification, Live Tile e Background Agent

@• É una notifica popup che appare in alto a destra sullo schermo.

• Template come per le tileshttp://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.toasttemplatetype

• Uno è poco due sono troppi da usare per comunicazioni importanti senza esagerare se non si vuole che l’utente le disabiliti.

Toast

Page 13: Push Notification, Live Tile e Background Agent

@• Package.appxmanifest• Tile primaria Square o Wide• Tile secondarie

Demo: Tiles

Page 14: Push Notification, Live Tile e Background Agent

@I contenuti delle tiles possono essere aggiornati tramite notifiche, in uno dei seguenti modi:• direttamente dall’ app• da un Task in background• da un Push Notification Message

Aggiornamenti tramite notifica

Page 15: Push Notification, Live Tile e Background Agent

@La notifica avviene tramite uno specifico formato xmlhttp://msdn.microsoft.com/en-us/library/windows/apps/br212853.aspx

La libreria WnsRecipe installabile tramite NuGet offre un model per semplificare la creazione delle notifiche per Tile, Toast e Badge

Xml di notifica

Page 16: Push Notification, Live Tile e Background Agent

@• Tile• Live tile• Toast• Badge

Demo: Notifiche

Page 17: Push Notification, Live Tile e Background Agent

@• Windows 8 consente alle Store App di eseguire operazioni anche se non sono correntemente attive (Running).

• L’esecuzione del Background task, una volta registrato, è gestito dal sistema operativo

• Tali operazioni sono eseguite in un host esterno all’applicazione (BackgroundTaskHost.exe) o all’interno della nostra App a seconda delle impostazioni o delle condizioni correnti della nostra App (Running, Suspended, Terminated)

• I task sono attivati attraverso Trigger specifici per ogni tipologia di evento e possono avere delle precondizioni

Background Tasks

Page 18: Push Notification, Live Tile e Background Agent

@Background Task: Triggers

Background task trigger type Trigger event When the background task is triggered ControlChannelTrigger 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 SmsReceived A new SMS message is received by an installed mobile broadband device.

SystemEventTrigger UserAway The user becomes absent.

SystemEventTrigger UserPresent The user becomes present.

TimeTrigger TimeTrigger A time event occurs.

Page 19: Push Notification, Live Tile e Background Agent

@Background Task: Task 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.

Page 20: Push Notification, Live Tile e Background Agent

@Background Task: Host types

Background task trigger type Host executable TimeTrigger Cannot be specified (default system host)

SystemTrigger Cannot be specified (default system host)

MaintenanceTrigger Cannot be specified (default system host)

PushNotificationTrigger Application provided exe OR Not specified (default system host)

ControlChannelTrigger Application provided exe

Page 21: Push Notification, Live Tile e Background Agent

@Ciclo di vita di un Background Task

Page 22: Push Notification, Live Tile e Background Agent

@• Background Task• Task progress e completion• Riassociazione handlers eventi

Demo: Background Task

Page 23: Push Notification, Live Tile e Background Agent

@Push notification: WNS

• Il Windows Push Notification Services (WNS) permette l’invio di notifiche alle nostre Windows Store App installate su un determinato device.

• Tramite WNS un servizio cloud o classico può inviare alla nostra Store App notifiche toast, tile, badge o raw.

• Il server ottiene un canale di comunicazione valido verso il WNS tramite il PackageSecurityidentifier ed il ClientSecret associati all’app.

Page 24: Push Notification, Live Tile e Background Agent

@Push notification: Come funziona?

Page 25: Push Notification, Live Tile e Background Agent

@• Richiesta di un Canale per le notifiche al client

• Simulazione di invio di notifiche da server

Demo: Push Notifications

Page 26: Push Notification, Live Tile e Background Agent

@• White papershttp://msdn.microsoft.com/en-us/library/windows/apps/hh465413.aspx

• Guidelines and checklist for tiles and badgeshttp://msdn.microsoft.com/en-us/library/windows/apps/hh465403.aspx

• Guidelines and checklist for background taskshttp://msdn.microsoft.com/en-us/library/windows/apps/hh977043.aspx

• Guidelines and checklist for push notificationshttp://msdn.microsoft.com/en-us/library/windows/apps/Hh761462.aspx

• Sampleshttp://code.msdn.microsoft.com/windowsapps

Riferimenti e risorse

Page 27: Push Notification, Live Tile e Background Agent

@Grazie agli sponsor