Comment je ne rate plus mon train
-
Upload
cocoaheads-france -
Category
Software
-
view
2.959 -
download
0
Transcript of Comment je ne rate plus mon train
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é fonctionnel3 minutes d’attente max en gare
Notification pour indiquer le départ
Côté techniqueSwift 2.2
XibAPI 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é 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
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
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
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”) {...}
MerciQuestions ?
https://github.com/DanYellow/SNCF_API