Comment je ne rate plus mon train

19
Comment je ne rate plus mon train (ou presque) Danielo Jean-Louis • Cocoaheads Paris - Juin 2016

Transcript of Comment je ne rate plus mon train

Page 1: Comment je ne rate plus mon train

Comment je ne rate plus mon train (ou presque)

Danielo Jean-Louis • Cocoaheads Paris - Juin 2016

Page 2: Comment je ne rate plus mon train

Développeur front-end chez DigitasLBI France

Levallois-Perret

Non loin de la gare de Clichy-Levallois

Page 3: Comment je ne rate plus mon train

J’oublie de consulter les horaires du train

Je cours pour essayer d’avoir mon train

Je le rate bien souvent car je ne suis pas parti au bon moment

A chaque fois que je pars du travail

Page 4: Comment je ne rate plus mon train

Applications qui auraient pu m’aider

Citymapper SNCF Transilien

Page 5: Comment je ne rate plus mon train

Une app pour ça (prototype)

Côté fonctionnel3 minutes d’attente max en gare

Notification pour indiquer le départ

Côté techniqueSwift 2.2

XibAPI SNCF

Page 6: Comment je ne rate plus mon train

Réponse JSON - Uniquement en GET

Limite : 90 000 requêtes/mois - Dont 3 000 requêtes/jour

Autorisation : Remplissage d’un formulaire

Impossibilité de filtrer par ligne

API SNCF - Points importants

let apiLink:String = “https://api.sncf.com/v1/coverage/sncf/places?q=/(NOM_DE_GARE)”

Github de la SNCF : https://github.com/SNCFdevelopers/API-trains-sncf/blob/master/source/integration.rst

Page 7: Comment je ne rate plus mon train

Réponse XML - Uniquement en GET

Limite : 20 requêtes/minute

Autorisation : Demande par mail

API SNCF - Horaires temps réel

Page 8: Comment je ne rate plus mon train

Exemple données API SNCF Horaires temps réel

<?xml version=”1.0” encoding=”UTF-8”?> <passages gare=”87276386”> <train> <date mode=”R”>01/06/2016 10:06</date> <num>125746</num> <miss>AOMA</miss> <term>87271031</term> </train> ... </passages>

let apiLink:String = “http://api.transilien.com/gare/\(departureStationId)/depart/\(arrivalStationId)”

Mode / Horaire

ID gare de départ

Numéro du train

ID du terminus

Page 9: Comment je ne rate plus mon train

Prototype réussi- Je sais quand je dois partir... et je ne rate plus mon train...

...Mais je ne peux pas gérer plusieurs gares et tout est en dur dans le code

Page 10: Comment je ne rate plus mon train

Nouveau design

Page 11: Comment je ne rate plus mon train

Direction du train (Gare de départ -> Gare d’arrivée)

Durée du trajet Recherche horaires

Page 12: Comment je ne rate plus mon train

Nouvelle version

Côté fonctionnel3 minutes d’attente max en gare

Notification pour indiquer le départAjout de trajet

Possibilité de reporter son départChanger le temps de parcours

Côté techniqueSwift 2.2

XibAPI SNCFAlamofireMapKit

Autolayout (SnapKit)CoreData (MagicalRecord)

UIAutomationUIMutableUserNotificationAction

Page 13: Comment je ne rate plus mon train

Fonctionnement

Demande d’horaires pour une gare donnéeRécupération de la position de l’utilisateur

Calcul du temps de(s) trajet(s) (Utilisateur -> Gare)Affichage du premier train eligible / Création d’une notification

Page 14: Comment je ne rate plus mon train

Nouvelle version

Côté fonctionnel3 minutes d’attente max en gare

Notification pour indiquer le départAjout de trajet

Possibilité de reporter son départChanger le temps de parcours

Côté techniqueSwift 2.2

XibAPI SNCFAlamofireMapKit

Autolayout (SnapKit)CoreData (MagicalRecord)

UIAutomationUIMutableUserNotificationAction

Page 15: Comment je ne rate plus mon train

UIMutableUserNotificationAction

API iOS 8

Permet d’interagir avec une notification via des actions définies

Via des boutons

Possibilité d’afficher un champ de texte (iOS 9+)

Page 16: Comment je ne rate plus mon train

UIMutableUserNotificationAction

let myMUNA = UIMutableUserNotificationAction();myMUNA.identifier = POSTPONE_SCHEDULE;myMUNA.title = "Prendre le prochain";myMUNA.destructive = false;myMUNA.authenticationRequired = false;myMUNA.activationMode = UIUserNotificationActivationMode.Background;

...

let myMNC = UIMutableUserNotificationCategory();myMNC.identifier = NotificationID.MY_IDENTIFIER;myMNC.setActions([myMUNA, myMUNA2, myMUNA3, myMUNA4], forContext: UIUserNotificationActionContext.Default);myMNC.setActions([myMUNA, myMUNA4], forContext: UIUserNotificationActionContext.Minimal);

let notification = UILocalNotification();...notification.identifier = NotificationID.MY_IDENTIFIER;

Page 17: Comment je ne rate plus mon train

.Minimal .Default

Page 18: Comment je ne rate plus mon train

UIMutableUserNotificationAction

application:handleActionWithIdentifier:forLocalNotification:completionHandler:application:handleActionWithIdentifier:forRemoteNotification:completionHandler:

if (identifier == “IDENTIFIER_1”) { NSNotificationCenter.defaultCenter() .postNotificationName( "NOTIFICATION_NAME", object: nil, userInfo: notification.userInfo);} else if (identifier == “IDENTIFIER_2”) {...}

Page 19: Comment je ne rate plus mon train

MerciQuestions ?

https://github.com/DanYellow/SNCF_API