function sendIOSCustomizedcast() { try { $customizedcast = new IOSCustomizedcast(); $customizedcast->setAppMasterSecret($this->appMasterSecret); $customizedcast->setPredefinedKeyValue("appkey", $this->appkey); $customizedcast->setPredefinedKeyValue("timestamp", $this->timestamp); // Set your alias here, and use comma to split them if there are multiple alias. // And if you have many alias, you can also upload a file containing these alias, then // use file_id to send customized notification. $customizedcast->setPredefinedKeyValue("alias", "xx"); // Set your alias_type here $customizedcast->setPredefinedKeyValue("alias_type", "xx"); $customizedcast->setPredefinedKeyValue("alert", "IOS 个性化测试"); $customizedcast->setPredefinedKeyValue("badge", 0); $customizedcast->setPredefinedKeyValue("sound", "chime"); // Set 'production_mode' to 'true' if your app is under production mode $customizedcast->setPredefinedKeyValue("production_mode", "false"); print "Sending customizedcast notification, please wait...\r\n"; $customizedcast->send(); print "Sent SUCCESS\r\n"; } catch (Exception $e) { print "Caught exception: " . $e->getMessage(); } }
private static function sendIOSCustomizedcast($uid, $ex, $test_model = 1) { $appMasterSecret = "aekwnddph20oq23mgubtgva268xpy1ms"; $appkey = "55f0efc4e0f55acbfd0027e0"; try { $customizedcast = new \IOSCustomizedcast(); $customizedcast->setAppMasterSecret($appMasterSecret); $customizedcast->setPredefinedKeyValue("appkey", $appkey); $customizedcast->setPredefinedKeyValue("timestamp", strval(time())); // Set your alias here, and use comma to split them if there are multiple alias. // And if you have many alias, you can also upload a file containing these alias, then // use file_id to send customized notification. $customizedcast->setPredefinedKeyValue("alias", $uid); // Set your alias_type here $customizedcast->setPredefinedKeyValue("alias_type", "UID"); // $customizedcast->setPredefinedKeyValue("alert", ""); $customizedcast->setPredefinedKeyValue("badge", 0); // $customizedcast->setPredefinedKeyValue("sound", "chime"); // Set 'production_mode' to 'true' if your app is under production mode if ($test_model) { $customizedcast->setPredefinedKeyValue("production_mode", "false"); } else { $customizedcast->setPredefinedKeyValue("production_mode", "true"); } $customizedcast->setPredefinedKeyValue('display_type', 'message'); $customizedcast->setPredefinedKeyValue('description', 'V1.3' . date("Y-m-d H:i:s")); foreach ($ex as $key => $value) { // var_dump($key); // echo "<br/>"; // var_dump($value); // echo "<br/>"; $customizedcast->setCustomizedField((string) $key, $value); } //print("Sending customizedcast notification, please wait...\r\n"); $customizedcast->send(); // print("Sent SUCCESS\r\n"); } catch (\Exception $e) { // print("Caught exception: " . $e->getMessage()); } // }