$message = "$shuttle arriving at $stopname in $minutes minutes ($timestr)"; break; case 'schedule': // $stopname was defined earlier $message = "$shuttle (NOT GPS TRACKED) scheduled to arrive at $stopname in $minutes minutes ($timestr)"; break; } //$stopname = ShuttleSchedule::get_stop_title($route_id, $stop_id); switch ($row['device_type']) { case 'apple': $aps = array('aps' => array('alert' => $message, 'sound' => 'default')); APNS_DB::create_notification($row['device_id'], "shuttletrack:$route_id:$stop_id", $aps, False); break; } // make sure to unsubscribe this person so they don't // get a message every 10 seconds until their subscription times out $sql = "DELETE FROM ShuttleSubscription " . "WHERE device_id='" . $row['device_id'] . "' " . "AND device_type='" . $row['device_type'] . "' " . "AND route_id='" . $route_id . "' " . "AND stop_id='" . $stop_id . "'"; if (!db::$connection->query($sql)) { d_error("unsubscribe failed: {$db->errno} {$db->error} in $sql"); } } // if
public function queue_notification($device_id) { APNS_DB::create_notification($device_id, "stellar:{$this->subject_id}", $this->data); }
$data = $emergency->get_feed(); if($data !== False) { $new_version = intval($data[0]['version']); } if($version && ($new_version > $version)) { // there is emergency unfortunately we now have to notify ALL devices db::ping(); $emergency_apns = array('aps' => array('alert' => substr($data[0]['text'], 0, 100), 'sound' => 'default') ); $result = APNS_DB::get_all_devices(); while($row = $result->fetch_assoc()) { APNS_DB::create_notification($row['device_id'], "emergencyinfo:", $emergency_apns); } $result->close(); } if($new_version > 0) { $version = $new_version; save_version($version); } } $daemon->stop(); /* these functions are for saving and grabbing the emergency version from disk that way the daemon is robust to being restarted */