<?php

require_once __DIR__ . "/autoload/session.autoload.php";
require_once __DIR__ . "/autoload/db.autoload.php";
require_once __DIR__ . "/class/IosPushNotificationCenter.php";
$iosPushNotificationCenter = new IosPushNotificationCenter();
if (isset($_GET['token'])) {
    $token = $_GET['token'];
    $iosPushNotificationCenter->registerToken($token);
    echo "{register: 'success'}";
}
 /**
  * Sends a push notification to all iOS devices with La Bourse iOS app
  */
 public function alertIosDevices()
 {
     $this->Transaction->setDate(date("d/m/Y"));
     $globals = $this->Transaction->getGlobalsWithDATE();
     foreach ($globals as $key => $value) {
         //Send an alert to iOS devices as well.
         $iOSMessage = 'Résultat ' . $value['magasin'] . ' : ' . $value['chiffre_journee'] . ' €';
         $iosPushNotificationCenter = new IosPushNotificationCenter();
         $iosPushNotificationCenter->broadcastNotification($iOSMessage);
     }
 }