Comment je ne rate plus mon train (ou presque)
Danielo Jean-Louis • Cocoaheads Paris - Juin 2016
Développeur front-end chez DigitasLBI France
Levallois-Perret
Non loin de la gare de Clichy-Levallois
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
Applications qui auraient pu m’aider
Citymapper SNCF Transilien
Une app pour ça (prototype)
Côté fonctionnel
3 minutes d’attente max en gare
Notification pour indiquer le départ
Côté technique
Swift 2.2
Xib
API SNCF
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
Réponse XML - Uniquement en GET
Limite : 20 requêtes/minute
Autorisation : Demande par mail
API SNCF - Horaires temps réel
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
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
Nouveau design
Direction du train (Gare de départ -> Gare d’arrivée)
Durée du trajet Recherche horaires
Nouvelle version
Côté fonctionnel
3 minutes d’attente max en gare
Notification pour indiquer le départ
Ajout de trajet
Possibilité de reporter son départ
Changer le temps de parcours
Côté technique
Swift 2.2
Xib
API SNCF
Alamofire
MapKit
Autolayout (SnapKit)
CoreData (MagicalRecord)
UIAutomation
UIMutableUserNotificationAction
Fonctionnement
Demande d’horaires pour une gare donnée
Ré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
Nouvelle version
Côté fonctionnel
3 minutes d’attente max en gare
Notification pour indiquer le départ
Ajout de trajet
Possibilité de reporter son départ
Changer le temps de parcours
Côté technique
Swift 2.2
Xib
API SNCF
Alamofire
MapKit
Autolayout (SnapKit)
CoreData (MagicalRecord)
UIAutomation
UIMutableUserNotificationAction
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+)
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;
.Minimal .Default
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”) {...}
Merci
Questions ?
https://github.com/DanYellow/SNCF_API

Comment je ne rate plus mon train

  • 1.
    Comment je nerate plus mon train (ou presque) Danielo Jean-Louis • Cocoaheads Paris - Juin 2016
  • 2.
    Développeur front-end chezDigitasLBI France Levallois-Perret Non loin de la gare de Clichy-Levallois
  • 3.
    J’oublie de consulterles 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
  • 4.
    Applications qui auraientpu m’aider Citymapper SNCF Transilien
  • 5.
    Une app pourça (prototype) Côté fonctionnel 3 minutes d’attente max en gare Notification pour indiquer le départ Côté technique Swift 2.2 Xib API SNCF
  • 6.
    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
  • 7.
    Réponse XML -Uniquement en GET Limite : 20 requêtes/minute Autorisation : Demande par mail API SNCF - Horaires temps réel
  • 8.
    Exemple données APISNCF 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
  • 9.
    Prototype réussi - Jesais 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
  • 10.
  • 11.
    Direction du train(Gare de départ -> Gare d’arrivée) Durée du trajet Recherche horaires
  • 12.
    Nouvelle version Côté fonctionnel 3minutes d’attente max en gare Notification pour indiquer le départ Ajout de trajet Possibilité de reporter son départ Changer le temps de parcours Côté technique Swift 2.2 Xib API SNCF Alamofire MapKit Autolayout (SnapKit) CoreData (MagicalRecord) UIAutomation UIMutableUserNotificationAction
  • 13.
    Fonctionnement Demande d’horaires pourune gare donnée Ré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
  • 14.
    Nouvelle version Côté fonctionnel 3minutes d’attente max en gare Notification pour indiquer le départ Ajout de trajet Possibilité de reporter son départ Changer le temps de parcours Côté technique Swift 2.2 Xib API SNCF Alamofire MapKit Autolayout (SnapKit) CoreData (MagicalRecord) UIAutomation UIMutableUserNotificationAction
  • 15.
    UIMutableUserNotificationAction API iOS 8 Permetd’interagir avec une notification via des actions définies Via des boutons Possibilité d’afficher un champ de texte (iOS 9+)
  • 16.
    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;
  • 17.
  • 18.
    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”) {...}
  • 19.