Exemplo n.º 1
0
require_once "../objects/Settings.php";
require_once "../objects/Core.php";
require_once "../objects/models/DeviceRegistration.php";
$core = new Core();
global $core;
$core->debugger(Settings::$debug);
$db = new DatabaseConn(Settings::$db_server, Settings::$db_user, Settings::$db_pass, Settings::$db_name);
$db_sets = array("prod" => $db);
$db_key = "prod";
$core->connect_db($db_sets[$db_key], $db_key, true);
$core->debug("Database Connected");
$retArr = array();
if ($_GET["deviceid"]) {
    try {
        $regObj = DeviceRegistration::create($core->escape($_GET["deviceid"]));
    } catch (Exception $e) {
        $retArr["error"] = $e->getMessage();
    }
    if ($regObj) {
        $retArr["status"] = true;
    } else {
        $retArr["status"] = false;
    }
} else {
    $retArr["status"] = false;
}
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Max-Age: 86400');
Exemplo n.º 2
0
require_once "../objects/Core.php";
require_once "../objects/models/DeviceRegistration.php";
require_once "../objects/controllers/GCMPush.php";
require_once "../objects/Settings.php";
$core = new Core();
global $core;
$core->debugger(Settings::$debug);
$db = new DatabaseConn(Settings::$db_server, Settings::$db_user, Settings::$db_pass, Settings::$db_name);
$db_sets = array("prod" => $db);
$db_key = "prod";
$core->connect_db($db_sets[$db_key], $db_key, true);
$core->debug("Database Connected");
$gcm = new GCMPush();
$gcm->setAPIKey(Settings::$gcm_key);
if ($_GET["action"] == "delete") {
    DeviceRegistration::deleteAll();
}
$count = sizeof($gcm->getAllIDs());
?>
<h1>There are <?php 
echo $count;
?>
 IDs registered in the database</h1>
<?php 
if ($count > 0) {
    ?>
  <form method="get">
  <h3>Please enter the message you want to push...</h3>
  <input type="text" name="pushmsg"><input type="submit" value="Push!">
  <input type="hidden" name="action" value="push">
  </form>
Exemplo n.º 3
0
 function pushToOne(DeviceRegistration $regEntry, $msgArr)
 {
     $arr = array($regEntry->getID());
     return $this->executePush($arr, $msgArr);
 }