Beispiel #1
0
 function sendAndroidUnicast()
 {
     try {
         $unicast = new AndroidUnicast();
         $unicast->setAppMasterSecret($this->appMasterSecret);
         $unicast->setPredefinedKeyValue("appkey", $this->appkey);
         $unicast->setPredefinedKeyValue("timestamp", $this->timestamp);
         // Set your device tokens here
         $unicast->setPredefinedKeyValue("device_tokens", "xx");
         $unicast->setPredefinedKeyValue("ticker", "Android unicast ticker");
         $unicast->setPredefinedKeyValue("title", "Android unicast title");
         $unicast->setPredefinedKeyValue("text", "Android unicast text");
         $unicast->setPredefinedKeyValue("after_open", "go_app");
         // Set 'production_mode' to 'false' if it's a test device.
         // For how to register a test device, please see the developer doc.
         $unicast->setPredefinedKeyValue("production_mode", "true");
         // Set extra fields
         $unicast->setExtraField("test", "helloworld");
         print "Sending unicast notification, please wait...\r\n";
         $unicast->send();
         print "Sent SUCCESS\r\n";
     } catch (Exception $e) {
         print "Caught exception: " . $e->getMessage();
     }
 }
Beispiel #2
0
 function sendAndroidUnicast($arr)
 {
     //        $this->sendAndroidBroadcast($arr);
     try {
         $unicast = new AndroidUnicast();
         $unicast->setAppMasterSecret($this->appMasterSecret);
         $unicast->setPredefinedKeyValue("appkey", $this->appkey);
         $unicast->setPredefinedKeyValue("timestamp", $this->timestamp);
         // Set your device tokens here
         $unicast->setPredefinedKeyValue("device_tokens", $arr['device_tokens']);
         $unicast->setPredefinedKeyValue("ticker", $arr['ticker']);
         $unicast->setPredefinedKeyValue("title", $arr['title']);
         $unicast->setPredefinedKeyValue("text", $arr['text']);
         $unicast->setPredefinedKeyValue("after_open", "go_app");
         $unicast->setPredefinedKeyValue("description", $arr['text']);
         // Set 'production_mode' to 'false' if it's a test device.
         // For how to register a test device, please see the developer doc.
         $unicast->setPredefinedKeyValue("production_mode", "true");
         // Set extra fields
         $unicast->setExtraField("code", $arr['code'] ? $arr['code'] : 0);
         //			print("Sending unicast notification, please wait...\r\n");
         $unicast->send();
         //			print("Sent SUCCESS\r\n");
         return true;
     } catch (Exception $e) {
         return false;
         print "Caught exception: " . $e->getMessage();
         die;
     }
 }