|
@@ -26,20 +26,16 @@ class push_sender
|
|
|
private function sendAndroidCustomizedcast(array $pushinfo)
|
|
|
{
|
|
|
$customizedcast = new AndroidCustomizedcast();
|
|
|
+
|
|
|
$customizedcast->setAppMasterSecret($this->androd_appmastersecret);
|
|
|
$customizedcast->setPredefinedKeyValue("appkey", $this->androd_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", $pushinfo['member_id']);
|
|
|
- // Set your alias_type here
|
|
|
$customizedcast->setPredefinedKeyValue("alias_type", $this->android_alias_type);
|
|
|
$customizedcast->setPredefinedKeyValue("ticker", $pushinfo['text']);
|
|
|
$customizedcast->setPredefinedKeyValue("title", $pushinfo['text']);
|
|
|
$customizedcast->setPredefinedKeyValue("text", $pushinfo['text']);
|
|
|
$customizedcast->setPredefinedKeyValue("after_open", "go_app");
|
|
|
- //Set extra fields
|
|
|
$customizedcast->setExtraField("go_type", $pushinfo['go_type']);
|
|
|
|
|
|
return $customizedcast->send();
|
|
@@ -52,24 +48,48 @@ class push_sender
|
|
|
$customizedcast->setAppMasterSecret($this->ios_appmastersecret);
|
|
|
$customizedcast->setPredefinedKeyValue("appkey", $this->ios_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", $pushinfo['member_id']);
|
|
|
- // Set your alias_type here
|
|
|
$customizedcast->setPredefinedKeyValue("alias_type", $this->ios_alias_type);
|
|
|
$customizedcast->setPredefinedKeyValue("alert", $pushinfo['text']);
|
|
|
$customizedcast->setPredefinedKeyValue("badge", 0);
|
|
|
$customizedcast->setPredefinedKeyValue("sound", "chime");
|
|
|
- // Set 'production_mode' to 'true' if your app is under production mode
|
|
|
$customizedcast->setPredefinedKeyValue("production_mode", "true");
|
|
|
- //Set extra fields
|
|
|
+
|
|
|
$customizedcast->setCustomizedField("go_type", $pushinfo['go_type']);
|
|
|
|
|
|
return $customizedcast->send();
|
|
|
}
|
|
|
|
|
|
+ private function sendAndroidCustomizedcastMessage(array $pushinfo)
|
|
|
+ {
|
|
|
+ $customizedcast = new AndroidCustomizedcast();
|
|
|
+ $customizedcast->setAppMasterSecret($this->androd_appmastersecret);
|
|
|
+ $customizedcast->setPredefinedKeyValue("appkey", $this->androd_appkey);
|
|
|
+ $customizedcast->setPredefinedKeyValue("timestamp", $this->timestamp);
|
|
|
+ $customizedcast->setPredefinedKeyValue("alias", $pushinfo['member_id']);
|
|
|
+ $customizedcast->setPredefinedKeyValue("alias_type", $this->android_alias_type);
|
|
|
+ $customizedcast->setPredefinedKeyValue("display_type", 'message');
|
|
|
+ $customizedcast->setPredefinedKeyValue("production_mode", "true");
|
|
|
+ $customizedcast->setPredefinedKeyValue("custom", json_encode($pushinfo['custom']));
|
|
|
+ return $customizedcast->send();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function sendIOSCustomizedcastMessage(array $pushinfo)
|
|
|
+ {
|
|
|
+ $customizedcast = new IOSCustomizedcast();
|
|
|
+ $customizedcast->setAppMasterSecret($this->ios_appmastersecret);
|
|
|
+ $customizedcast->setPredefinedKeyValue("appkey", $this->ios_appkey);
|
|
|
+ $customizedcast->setPredefinedKeyValue("timestamp", $this->timestamp);
|
|
|
+ $customizedcast->setPredefinedKeyValue("alias", $pushinfo['member_id']);
|
|
|
+ $customizedcast->setPredefinedKeyValue("alias_type", $this->ios_alias_type);
|
|
|
+ $customizedcast->setPredefinedKeyValue("display_type", 'message');
|
|
|
+ $customizedcast->setPredefinedKeyValue("alert", $pushinfo['text']);
|
|
|
+ $customizedcast->setPredefinedKeyValue("production_mode", "true");
|
|
|
+ $customizedcast->setPredefinedKeyValue("custom", json_encode($pushinfo['custom']));
|
|
|
+
|
|
|
+ return $customizedcast->send();
|
|
|
+ }
|
|
|
+
|
|
|
public function send(array $info)
|
|
|
{
|
|
|
try
|
|
@@ -98,4 +118,33 @@ class push_sender
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ public function send_message(array $info)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $ret = $this->sendAndroidCustomizedcastMessage($info);
|
|
|
+ $data = json_decode($ret,true);
|
|
|
+ if(strtoupper($data['ret']) == 'SUCCESS') {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $ex) {
|
|
|
+ Log::record("push_app sendAndroid error",Log::ERR);
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $ret = $this->sendIOSCustomizedcastMessage($info);
|
|
|
+ $data = json_decode($ret,true);
|
|
|
+ if(strtoupper($data['ret']) == 'SUCCESS') {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $ex) {
|
|
|
+ Log::record("push_app sendAndroid error",Log::ERR);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|