Esempio n. 1
0
 function sendIOSUnicast()
 {
     try {
         $unicast = new IOSUnicast();
         $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("alert", "IOS 单播测试");
         $unicast->setPredefinedKeyValue("badge", 0);
         $unicast->setPredefinedKeyValue("sound", "chime");
         // Set 'production_mode' to 'true' if your app is under production mode
         $unicast->setPredefinedKeyValue("production_mode", "false");
         // Set customized fields
         $unicast->setCustomizedField("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();
     }
 }
Esempio n. 2
0
 function sendIOSUnicast($arr)
 {
     try {
         $unicast = new IOSUnicast();
         $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("alert", $arr['text']);
         $unicast->setPredefinedKeyValue("badge", 0);
         $unicast->setPredefinedKeyValue("sound", "chime");
         $unicast->setPredefinedKeyValue("description", $arr['text']);
         // Set 'production_mode' to 'true' if your app is under production mode
         $unicast->setPredefinedKeyValue("production_mode", "false");
         // Set customized fields
         $unicast->setCustomizedField("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;
     }
 }