diff --git a/push/UniPush/IGt.Batch.php b/push/UniPush/IGt.Batch.php new file mode 100644 index 0000000..82f1db3 --- /dev/null +++ b/push/UniPush/IGt.Batch.php @@ -0,0 +1,84 @@ +APPKEY = $appkey; + $this->push = $push; + $this->batchId = uniqid(); + + } + + public function getBatchId() + { + return $this->batchId; + } + + public function add($message, $target) + { + if ($this->seqId >= 5000) { + throw new Exception("Can not add over 5000 message once! Please call submit() first."); + } else { + $this->seqId += 1; + $innerMsg = new SingleBatchItem(); + $innerMsg->set_seqId($this->seqId); + $innerMsg->set_data($this->createSingleJson($message, $target)); + array_push($this->innerMsgList, $innerMsg); + } + return $this->seqId . ""; + } + + public function createSingleJson($message, $target) + { + $params = $this->push->getSingleMessagePostData($message,$target); + return json_encode($params); + } + + public function submit() + { + $requestId = LangUtils::randomUUID(); + $data = array(); + $data["appkey"]=$this->APPKEY; + $data["serialize"] = "pb"; + $data["async"] = GTConfig::isPushSingleBatchAsync(); + $data["action"] = "pushMessageToSingleBatchAction"; + $data['requestId'] = $requestId; + $singleBatchRequest = new SingleBatchRequest(); + $singleBatchRequest->set_batchId($this->batchId); + foreach ($this->innerMsgList as $index => $innerMsg) { + $singleBatchRequest->add_batchItem(); + $singleBatchRequest->set_batchItem($index, $innerMsg); + } + $data["singleDatas"] = base64_encode($singleBatchRequest->SerializeToString()); + $this->seqId = 0; + $this->innerMsgList = array(); + $this->lastPostData = $data; + $result = $this->push->httpPostJSON(null, $data, true); + return $result; + } + + public function retry() + { + $result = $this->push->httpPostJSON(null, $this->lastPostData, true); + return $result; + } + + public function setApiUrl($apiUrl) { + } +} \ No newline at end of file diff --git a/push/UniPush/IGt.Push.php b/push/UniPush/IGt.Push.php new file mode 100644 index 0000000..ee569d8 --- /dev/null +++ b/push/UniPush/IGt.Push.php @@ -0,0 +1,787 @@ +appkey = $appkey; + $this->masterSecret = $masterSecret; + + $domainUrl = trim($domainUrl); + if ($ssl == NULL && $domainUrl != NULL && strpos(strtolower($domainUrl), "https:") === 0) + { + $ssl = true; + } + + $this->useSSL = ($ssl == NULL ? false : $ssl); + + + if ($domainUrl == NULL || strlen($domainUrl) == 0) + { + $this->domainUrlList = GTConfig::getDefaultDomainUrl($this->useSSL); + } + else + { + $this->domainUrlList = array($domainUrl); + } + $this->initOSDomain(null); + } + + private function initOSDomain($hosts) + { + if($hosts == null || count($hosts) == 0) + { + $hosts = isset(IGeTui::$appkeyUrlList[$this->appkey])?IGeTui::$appkeyUrlList[$this->appkey]:null; + if($hosts == null || count($hosts) == 0) + { + $hosts = $this->getOSPushDomainUrlList($this->domainUrlList,$this->appkey); + IGeTui::$appkeyUrlList[$this->appkey] = $hosts; + } + } + else + { + IGeTui::$appkeyUrlList[$this->appkey] = $hosts; + } + $this->host = ApiUrlRespectUtils::getFastest($this->appkey, $hosts); + return $this->host; + } + + public function getOSPushDomainUrlList($domainUrlList,$appkey) + { + $urlList = null; + $postData = array(); + $postData['action']='getOSPushDomailUrlListAction'; + $postData['appkey'] = $appkey; + $ex = null; + foreach($domainUrlList as $durl) + { + try + { + $response = $this->httpPostJSON($durl,$postData); + $urlList = isset($response["osList"])?$response["osList"]:null; + if($urlList != null && count($urlList) > 0) + { + break; + } + } + catch (Exception $e) + { + $ex = $e; + } + } + if($urlList == null || count($urlList) <= 0) + { + $h = implode(',', $domainUrlList); + throw new Exception("Can not get hosts from ".$h."|error:".$ex); + } + return $urlList; + } + function httpPostJSON($url,$data,$gzip=false) + { + $data['version'] = GTConfig::getSDKVersion(); + $data['authToken'] = $this->authToken; + if($url == null){ + $url = $this->host; + } + $rep = HttpManager::httpPostJson($url, $data, $gzip); + if($rep != null) + { + if ( 'sign_error' == $rep['result']) { + try + { + if ($this->connect()) + { + $data['authToken'] = $this->authToken; + $rep = HttpManager::httpPostJson($url, $data, $gzip); + + } + } + catch (Exception $e) + { + throw new Exception("连接异常".$e); + } + } + else if('domain_error' == $rep['result']) + { + $this->initOSDomain(isset($rep["osList"])?$rep["osList"]:null); + $rep = HttpManager::httpPostJson($url, $data, $gzip); + } + } + return $rep; + } + + public function connect() + { + $timeStamp = $this->micro_time(); + // 计算sign值 + $sign = md5($this->appkey . $timeStamp . $this->masterSecret); + // + var_dump($sign); + $params = array(); + + $params["action"] = "connect"; + $params["appkey"] = $this->appkey; + $params["timeStamp"] = $timeStamp; + $params["sign"] = $sign; + $params["version"] = GTConfig::getSDKVersion(); + $rep = HttpManager::httpPostJson($this->host,$params,false); + if ('success' == $rep['result']) { + if($rep["authtoken"] != null){ + $this->authToken = $rep["authtoken"]; + } + return true; + } + throw new Exception("appKey Or masterSecret is Auth Failed"); + } + + public function close() + { + $params = array(); + $params["action"] = "close"; + $params["appkey"] = $this->appkey; + $params["version"] = GTConfig::getSDKVersion(); + $params["authtoken"] = $this->authToken; + HttpManager::httpPostJson($this->host,$params,false); + } + + /** + * 指定用户推送消息 + * @param IGtMessage message + * @param IGtTarget target + * @return Array {result:successed_offline,taskId:xxx} || {result:successed_online,taskId:xxx} || {result:error} + ***/ + public function pushMessageToSingle($message, $target, $requestId = null) + { + if($requestId == null || trim($requestId) == "") + { + $requestId = LangUtils::randomUUID(); + } + $params = $this->getSingleMessagePostData($message, $target, $requestId); + return $this->httpPostJSON($this->host,$params); + } + + + function getSingleMessagePostData($message, $target, $requestId = null){ + $params = array(); + $params["action"] = "pushMessageToSingleAction"; + $params["appkey"] = $this -> appkey; + if($requestId != null) + { + $params["requestId"] = $requestId; + } + + $params["clientData"] = base64_encode($message->get_data()->get_transparent()); + $params["transmissionContent"] = $message->get_data()->get_transmissionContent(); + $params["isOffline"] = $message->get_isOffline(); + $params["offlineExpireTime"] = $message->get_offlineExpireTime(); + // 增加pushNetWorkType参数(0:不限;1:wifi;2:4G/3G/2G) + $params["pushNetWorkType"] = $message->get_pushNetWorkType(); + + // + $params["appId"] = $target->get_appId(); + $params["clientId"] = $target->get_clientId(); + $params["alias"] = $target->get_alias(); + // 默认都为消息 + $params["type"] = 2; + $params["pushType"] = $message->get_data()->get_pushType(); + return $params; + } + + + public function getContentId($message,$taskGroupName = null) + { + return $this->getListAppContentId($message,$taskGroupName); + } + + /** + * 取消消息 + * @param String contentId + * @return boolean + ***/ + public function cancelContentId($contentId) + { + $params = array(); + $params["action"] = "cancleContentIdAction"; + $params["appkey"] = $this->appkey; + $params["contentId"] = $contentId; + $rep = $this->httpPostJSON($this->host,$params); + return $rep['result'] == 'ok' ? true : false; + } + + /** + * 用户黑名单接口 + * @param appId + * @param cidList + * @param optType 1: 增加黑名单,2:恢复加入黑名单中的cid列表 + * @return + */ + private function blackCidList($appId,$cidList,$optType){ + $params = array(); + $limit = GTConfig::getMaxLenOfBlackCidList(); + if($limit < count($cidList)){ + throw new Exception("cid size:".count($cidList)." beyond the limit:".$limit); + } + $params["action"] = "blackCidAction"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["cidList"] = $cidList; + $params["optType"] = $optType; + return $this->httpPostJSON($this->host,$params); + } + + public function addCidListToBlk($appId,$cidList){ + + return $this->blackCidList($appId,$cidList,1); + + } + + public function restoreCidListFromBlk($appId,$cidList){ + + return $this->blackCidList($appId,$cidList,2); + + } + /** + * 批量推送信息 + * @param String contentId + * @param Array targetList + * @return Array {result:successed_offline,taskId:xxx} || {result:successed_online,taskId:xxx} || {result:error} + ***/ + public function pushMessageToList($contentId, $targetList) + { + $params = array(); + $params["action"] = "pushMessageToListAction"; + $params["appkey"] = $this->appkey;//? + $params["contentId"] = $contentId; + $needDetails = GTConfig::isPushListNeedDetails(); + $params["needDetails"] = $needDetails; + $async = GTConfig::isPushListAsync(); + $params["async"] = $async; + if($async && (!$needDetails)) + { + $limit = GTConfig::getAsyncListLimit(); + } + else + { + $limit = GTConfig::getSyncListLimit(); + } + if(count($targetList) > $limit) + { + throw new Exception("target size:".count($targetList)." beyond the limit:".$limit); + } + $clientIdList = array(); + $aliasList= array(); + $appId = null; + foreach($targetList as $target) + { + $targetCid = $target->get_clientId(); + $targetAlias = $target->get_alias(); + if($targetCid != null) + { + array_push($clientIdList,$targetCid); + }elseif($targetAlias != null) + { + array_push($aliasList,$targetAlias); + } + if($appId == null) + { + $appId = $target->get_appId(); + } + + } + $params["appId"] = $appId; + $params["clientIdList"] = $clientIdList; + $params["aliasList"] = $aliasList; + $params["type"] = 2; + return $this->httpPostJSON($this->host,$params,true); + } + + public function stop($contentId) + { + $params = array(); + $params["action"] = "stopTaskAction"; + $params["appkey"] = $this->appkey; + $params["contentId"] = $contentId; + $rep = $this->httpPostJSON($this->host, $params); + if ("ok" == $rep["result"]) { + return true; + } + return false; + } + + public function getClientIdStatus($appId, $clientId) + { + $params = array(); + $params["action"] = "getClientIdStatusAction"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["clientId"] = $clientId; + return $this->httpPostJSON($this->host, $params); + } + + public function setClientTag($appId, $clientId, $tags) + { + $params = array(); + $params["action"] = "setTagAction"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["clientId"] = $clientId; + $params["tagList"] = $tags; + return $this->httpPostJSON($this->host, $params); + } + + /** + * 设置 iphone Badge + * @param badge + * @param appid + * @param deviceTokenList + * @param cidList + * @return + */ + + private function setBadge($badge,$appid,$deviceTokenList,$cidList){ + $params = array(); + $params["action"] = "setBadgeAction"; + $params["appkey"] = $this->appkey; + $params["badge"] = $badge; + $params["appid"] = $appid; + $params["deviceToken"] = $deviceTokenList; + $params["cid"] = $cidList; + return $this->httpPostJSON($this->host, $params); + + } + + public function setBadgeForCID($badge,$appid,$cidList){ + + return $this->setBadge($badge,$appid,array(), $cidList); + + } + public function setBadgeForDeviceToken($badge,$appid,$deviceTokenList){ + + return $this->setBadge($badge,$appid,$deviceTokenList, array()); + + } + + public function pushMessageToApp($message, $taskGroupName = null) + { + $contentId = $this->getListAppContentId($message, $taskGroupName); + $params = array(); + $params["action"] = "pushMessageToAppAction"; + $params["appkey"] = $this->appkey; + $params["contentId"] = $contentId; + $params["type"] = 2; + return $this->httpPostJSON($this->host,$params); + } + + private function getListAppContentId($message, $taskGroupName = null) + { + $params = array(); + if (!is_null($taskGroupName) && trim($taskGroupName) != ""){ + if(strlen($taskGroupName) > 40){ + throw new Exception("TaskGroupName is OverLimit 40"); + } + $params["taskGroupName"] = $taskGroupName; + } + $params["action"] = "getContentIdAction"; + $params["appkey"] = $this->appkey; + $params["clientData"] = base64_encode($message->get_data()->get_transparent()); + $params["transmissionContent"] = $message->get_data()->get_transmissionContent(); + $params["isOffline"] = $message->get_isOffline(); + $params["offlineExpireTime"] = $message->get_offlineExpireTime(); + // 增加pushNetWorkType参数(0:不限;1:wifi;2:4G/3G/2G) + $params["pushNetWorkType"] = $message->get_pushNetWorkType(); + $params["pushType"] = $message->get_data()->get_pushType(); + $params["type"] = 2; + //contentType 1是appMessage,2是listMessage + if ($message instanceof IGtListMessage){ + $params["contentType"] = 1; + } else { + $params["contentType"] = 2; + $params["appIdList"] = $message->get_appIdList(); + $params["speed"] = $message->get_speed(); + //定时时间 + if($message->getPushTime() != null && !empty($message->getPushTime())){ + $params["pushTime"] = $message->getPushTime(); + } + //$params["personaTags"] + $personaTags = array(); + if($message->get_conditions() == null) { + $params["phoneTypeList"] = $message->get_phoneTypeList(); + $params["provinceList"] = $message->get_provinceList(); + $params["tagList"] = $message->get_tagList(); + } else { + $conditions = $message->get_conditions(); + $params["conditions"] = $conditions->getCondition(); + } + } + $rep = $this->httpPostJSON($this->host,$params); + if($rep['result'] == 'ok') + { + return $rep['contentId']; + }else{ + throw new Exception("host:[".$this->host."]" + "获取contentId失败:" . $rep); + } + } + + public function getBatch() + { + return new IGtBatch($this->appkey,$this); + } + + public function pushAPNMessageToSingle($appId, $deviceToken, $message) + { + $params = array(); + $params['action'] = 'apnPushToSingleAction'; + $params['appId'] = $appId; + $params['appkey'] = $this->appkey; + $params['DT'] = $deviceToken; + $params['PI'] = base64_encode($message->get_data()->get_pushInfo()->SerializeToString()); + return $this->httpPostJSON($this->host,$params); + } + + /** + * 根据deviceTokenList群推 + * @param $appId + * @param $contentId + * @param $deviceTokenList + * @return mixed + */ + public function pushAPNMessageToList($appId, $contentId, $deviceTokenList) + { + $params = array(); + $params["action"] = "apnPushToListAction"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["contentId"] = $contentId; + $params["DTL"] = $deviceTokenList; + $needDetails = GTConfig::isPushListNeedDetails(); + $params["needDetails"]=$needDetails; + return $this->httpPostJSON($this->host,$params); + } + /** + * 获取apn contentId + * @param $appId + * @param $message + * @return string + */ + public function getAPNContentId($appId, $message) + { + $params = array(); + $params["action"] = "apnGetContentIdAction"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["PI"] = base64_encode($message->get_data()->get_pushInfo()->SerializeToString()); + $rep = $this->httpPostJSON($this->host,$params); + if($rep['result'] == 'ok'){ + return $rep['contentId']; + }else{ + throw new Exception("host:[".$this->host."]" + "获取contentId失败:".$rep); + } + } + + public function bindAlias($appId, $alias, $clientId) + { + $params = array(); + $params["action"] = "alias_bind"; + $params["appkey"] = $this->appkey; + $params["appid"] = $appId; + $params["alias"] = $alias;; + $params["cid"] = $clientId; + return $this->httpPostJSON($this->host,$params); + } + + public function bindAliasBatch($appId, $targetList) + { + $params = array(); + $aliasList = array(); + foreach($targetList as $target) { + $user = array(); + $user["cid"] = $target->get_clientId(); + $user["alias"] = $target->get_alias(); + array_push($aliasList, $user); + } + $params["action"] = "alias_bind_list"; + $params["appkey"] = $this->appkey; + $params["appid"] = $appId; + $params["aliaslist"] = $aliasList; + return $this->httpPostJSON($this->host,$params); + } + + public function queryClientId($appId, $alias) + { + $params = array(); + $params["action"] = "alias_query"; + $params["appkey"] = $this->appkey; + $params["appid"] = $appId; + $params["alias"] = $alias;; + return $this->httpPostJSON($this->host, $params); + } + + public function queryAlias($appId, $clientId) + { + $params = array(); + $params["action"] = "alias_query"; + $params["appkey"] = $this->appkey; + $params["appid"] = $appId; + $params["cid"] = $clientId; + return $this->httpPostJSON($this->host, $params); + } + + public function unBindAlias($appId, $alias, $clientId=null) + { + $params = array(); + $params["action"] = "alias_unbind"; + $params["appkey"] = $this->appkey; + $params["appid"] = $appId; + $params["alias"] = $alias; + if (!is_null($clientId) && trim($clientId) != "") + { + $params["cid"] = $clientId; + } + return $this->httpPostJSON($this->host, $params); + } + + public function unBindAliasAll($appId, $alias) + { + return $this->unBindAlias($appId, $alias); + } + + public function getPushResult( $taskId) { + $params = array(); + $params["action"] = "getPushMsgResult"; + $params["appkey"] = $this->appkey; + $params["taskId"] = $taskId; + return $this->httpPostJson($this->host, $params); + } + + public function getPushResultByGroupName($appId,$groupName){ + $params = array(); + $params["action"] = "getPushResultByGroupName"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["groupName"] = $groupName; + return $this->httpPostJSON($this->host, $params); + } + + public function getLast24HoursOnlineUserStatistics($appId){ + $params = array(); + $params["action"] = "getLast24HoursOnlineUser"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + + + return $this->httpPostJSON($this->host, $params); + + } + public function getPushResultByTaskidList( $taskIdList) { + return $this->getPushActionResultByTaskids($taskIdList, null); + } + + public function getPushActionResultByTaskids( $taskIdList, $actionIdList) { + $params = array(); + $params["action"] = "getPushMsgResultByTaskidList"; + $params["appkey"] = $this->appkey; + $params["taskIdList"] = $taskIdList; + $params["actionIdList"] = $actionIdList; + return $this->httpPostJson($this->host, $params); + } + + public function getUserTags($appId, $clientId) { + $params = array(); + $params["action"] = "getUserTags"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["clientId"] = $clientId; + return $this->httpPostJson($this->host, $params); + } + + public function getUserCountByTags($appId, $tagList) { + $params = array(); + $params["action"] = "getUserCountByTags"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["tagList"] = $tagList; + $limit = GTConfig::getTagListLimit(); + if(count($tagList) > $limit) { + throw new Exception("tagList size:".count($tagList)." beyond the limit:".$limit); + } + return $this->httpPostJSON($this->host, $params); + } + + public function getPersonaTags($appId) { + $params = array(); + $params["action"] = "getPersonaTags"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + + return $this->httpPostJSON($this->host, $params); + } + + public function queryAppPushDataByDate($appId, $date){ + if(!LangUtils::validateDate($date)){ + throw new Exception("DateError|".$date); + } + $params = array(); + $params["action"] = "queryAppPushData"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["date"] = $date; + return $this->httpPostJson($this->host, $params); + } + + public function queryAppUserDataByDate($appId, $date){ + if(!LangUtils::validateDate($date)){ + throw new Exception("DateError|".$date); + } + $params = array(); + $params["action"] = "queryAppUserData"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + $params["date"] = $date; + return $this->httpPostJson($this->host, $params); + } + + public function queryUserCount($appId, $appConditions) { + $params = array(); + $params["action"] = "queryUserCount"; + $params["appkey"] = $this->appkey; + $params["appId"] = $appId; + if(!is_null($appConditions)) { + $params["conditions"] = $appConditions->condition; + } + return $this->httpPostJson($this->host, $params); + } + + public function pushTagMessage($message, $requestId = null) { + if(!$message instanceof IGtTagMessage) { + return $this->get_result("MsgTypeError"); + } + if($requestId == null || trim($requestId) == "") { + $requestId = LangUtils::randomUUID(); + } + + $params = array(); + $params["action"] = "pushMessageByTagAction"; + $params["appkey"] = $this->appkey; + $params["clientData"] = base64_encode($message->get_data()->get_transparent()); + $params["transmissionContent"] = $message->get_data()->get_transmissionContent(); + $params["isOffline"] = $message->get_isOffline(); + $params["offlineExpireTime"] = $message->get_offlineExpireTime(); + $params["pushNetWorkType"] = $message->get_pushNetWorkType(); + $params["appIdList"] = $message->get_appIdList(); + $params["speed"] = $message->get_speed(); + $params["requestId"] = $requestId; + $params["tag"] = $message->get_tag(); + return $this->httpPostJSON($this->host, $params); + } + + public function pushTagMessageRetry($message) { + return $this->pushTagMessage($message,null); + } + public function getScheduleTask($taskId,$appId){ + $params = array(); + $params["action"] = "getScheduleTaskAction"; + $params["appId"] = $appId; + $params["appkey"] = $this->appkey; + $params["taskId"] = $taskId; + var_dump($this->host); + + return $this->httpPostJSON($this->host, $params); + + } + + public function delScheduleTask($taskId,$appId){ + $params = array(); + $params["action"] = "delScheduleTaskAction"; + $params["appId"] = $appId; + $params["appkey"] = $this->appkey; + $params["taskId"] = $taskId; + + return $this->httpPostJSON($this->host, $params); + + } + + public function bindCidPn($appId,$cidAndPn){ + $params = array(); + $params["action"] = "bind_cid_pn"; + $params["appId"] = $appId; + $params["appkey"] = $this->appkey; + $params["cidpnlist"] = $cidAndPn; + + return $this->httpPostJSON($this->host,$params); + } + + public function unbindCidPn($appId,$cid){ + $params = array(); + $params["action"] = "unbind_cid_pn"; + $params["appId"] = $appId; + $params["appkey"] = $this->appkey; + $params["cids"] = $cid; + + return $this->httpPostJSON($this->host,$params); + } + + public function queryCidPn($appId,$cid){ + $params = array(); + $params["action"] = "query_cid_pn"; + $params["appId"] = $appId; + $params["appkey"] = $this->appkey; + $params["cids"] = $cid; + + return $this->httpPostJSON($this->host,$params); + } + + public function stopSendSms($appId,$taskId){ + $params = array(); + $params["action"] = "stop_sms"; + $params["appId"] = $appId; + $params["appkey"] = $this->appkey; + $params["taskId"] = $taskId; + return $this->httpPostJSON($this->host,$params); + + } + + private function get_result($info) { + $ret = array(); + $ret["result"] = $info; + return $ret; + } + + private function micro_time() + { + list($usec, $sec) = explode(" ", microtime()); + $time = ($sec . substr($usec, 2, 3)); + return $time; + } +} diff --git a/push/UniPush/README.md b/push/UniPush/README.md new file mode 100644 index 0000000..2e4a2f9 --- /dev/null +++ b/push/UniPush/README.md @@ -0,0 +1,36 @@ +# 个推推送平台 + + +## 使用说明 +1. 打开config.php文件,配置以下常量值: + - APPID + 应用AppID,个推平台申请应用后可获取 + - APPKEY + 应用AppKey,个推平台申请应用后可获取 + - MASTERSECRET + 应用MasterSecret,个推平台申请应用后可获取 + - HOST + 个推推送平台服务器地址,推荐使用默认值即可 + - PACKAGENAME + 应用包名,HBuilderX提交云端打包设置的包名 + + +2. 部署服务器后访问以下页面发送推送消息 + - index.php + 下发推送通知页面,输入cid参数后点击“发送推送通知”按钮 + +**HBuilderX默认的真机运行基座可在此页面发送[https://demo.dcloud.net.cn/push/unipush.HBuilder/index.php](https://demo.dcloud.net.cn/push/unipush.HBuilder/index.php)** + + +##常见问题 + +###设置代理 +如果开发者自己业务服务器需要通过代理访问外网,请在igetui\utils\HttpManager.php页面 +查找以下代码修改为部署服务器环境的代理服务器 +``` +curl_setopt($curl, CURLOPT_PROXY, '10.241.32.57:3128');//修改为服务器环境的代理地址 +``` + +###支持语言 +这里仅提供PHP示例,官方还支持C#、JAVA、PYTHON、Node.js、C++等语言,请参考个推官方[文档中心](http://docs.getui.com/)。 + diff --git a/push/UniPush/config.php b/push/UniPush/config.php new file mode 100644 index 0000000..3f3a95e --- /dev/null +++ b/push/UniPush/config.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/push/UniPush/exception/RequestException.php b/push/UniPush/exception/RequestException.php new file mode 100644 index 0000000..0a6c0c6 --- /dev/null +++ b/push/UniPush/exception/RequestException.php @@ -0,0 +1,21 @@ +requestId = $requestId; + } + public function getRequestId() + { + return $this->requestId; + } +} \ No newline at end of file diff --git a/push/UniPush/igetui.php b/push/UniPush/igetui.php new file mode 100644 index 0000000..bdc5e78 --- /dev/null +++ b/push/UniPush/igetui.php @@ -0,0 +1,206 @@ +set_appId(APPID);//应用appid + $template->set_appkey(APPKEY);//应用appkey + $template->set_transmissionType(1);//透传消息类型,Android平台控制点击消息后是否启动应用 + if(!empty($p)){ + $template->set_transmissionContent($p);//透传内容,点击消息后触发透传数据 + } + $template->set_title($t);//通知栏标题 + $template->set_text($c);//通知栏内容 +// $template->set_logo("http://wwww.igetui.com/logo.png");//通知栏logo,不设置使用默认程序图标 + $template->set_isRing(true);//是否响铃 + $template->set_isVibrate(true);//是否震动 + $template->set_isClearable(true);//通知栏是否可清除 + + return $template; +} + + +/** + * 创建链接通知 + * @param $t 推送通知标题 + * @param $c 推送通知内容 + * @param $l 推送通知链接地址 + * @return IGtLinkTemplate + */ +function createLinkMessage($t, $c, $l){ + $template = new IGtLinkTemplate(); + $template ->set_appId(APPID);//应用appid + $template ->set_appkey(APPKEY);//应用appkey + $template ->set_title($t);//通知栏标题 + $template ->set_text($c);//通知栏内容 +// $template->set_logo("http://wwww.igetui.com/logo.png");//通知栏logo,不设置使用默认程序图标 + $template ->set_isRing(true);//是否响铃 + $template ->set_isVibrate(true);//是否震动 + $template ->set_isClearable(true);//通知栏是否可清除 + $template ->set_url($l);//打开连接地址 + //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 + + return $template; +} + + +/** + * 创建下载通知 + * @param $t 推送通知标题 + * @param $c 推送通知内容 + * @param $pt 点击通知后弹框标题 + * @param $pc 点击通知后弹框内容 + * @param $dt 下载进度框标题 + * @param $dl 下载链接地址 + * @return IGtNotyPopLoadTemplate + */ +function createDownMessage($t, $c, $pt, $pc, $dt, $dl ){ + $template = new IGtNotyPopLoadTemplate(); + + $template ->set_appId(APPID);//应用appid + $template ->set_appkey(APPKEY);//应用appkey + //通知栏 + $template ->set_notyTitle($t);//通知栏标题 + $template ->set_notyContent($c);//通知栏内容 + $template ->set_notyIcon("");//通知栏logo + $template ->set_isBelled(true);//是否响铃 + $template ->set_isVibrationed(true);//是否震动 + $template ->set_isCleared(true);//通知栏是否可清除 + //弹框 + $template ->set_popTitle($pt);//弹框标题 + $template ->set_popContent($pc);//弹框内容 +// $template ->set_popImage("");//弹框图片 + $template ->set_popButton1("下载");//左键 + $template ->set_popButton2("取消");//右键 + //下载 +// $template ->set_loadIcon("");//弹框图片 + $template ->set_loadTitle($dt); + $template ->set_loadUrl($dl); + $template ->set_isAutoInstall(false); + $template ->set_isActived(true); + //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 + + return $template; +} + + +/** + * 创建透传通知 + * @param $p 推送数据内容 + * @return IGtNotificationTemplate + */ +function createTranMessage($p){ + $template = new IGtTransmissionTemplate(); + $template->set_appId(APPID);//应用appid + $template->set_appkey(APPKEY);//应用appkey + $template->set_transmissionType(2);//透传消息类型:1为激活客户端启动 + $template->set_transmissionContent($p);//透传内容 + //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 + + //当透传消息满足格式{title:'',content:'',payload:''}时兼容支持厂商推送通道 + $jp = json_decode($p, true); + if(!empty($jp) && !empty($jp['title']) && !empty($jp['content'])){ + $title = $jp['title']; + $content = $jp['content']; + $paload = empty($jp['payload'])?'':$jp['payload']; + $pn = PACKAGENAME; + + $notify = new IGtNotify(); + $notify->set_title($jp['title']); + $notify->set_content($jp['content']); + $notify->set_intent("intent:#Intent;action=android.intent.action.oppopush;component={$pn}/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title={$title};S.content={$content};S.payload={$payload};end"); + $notify->set_type(NotifyInfo_type::_intent); + + $template->set3rdNotifyInfo($notify); + } + + return $template; +} + + + +// 创建推送对象 +$igt = new IGeTui(HOST,APPKEY,MASTERSECRET); + + +/** + * 单推APN接口示例 + * @param $token 推送的客户端APN标识 + * @param $c 推送消息显示的内容 + * @param $p 推送消息的数据内容 + */ +function apnMessageToSingle($token,$c,$p){ + global $igt; + + $template = new IGtAPNTemplate(); + //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage); + $template->set_pushInfo("", 1, $c, "", $p, "", "", ""); + + //单个用户推送接口 + $message = new IGtSingleMessage(); + $message->set_data($template); + $ret = $igt->pushAPNMessageToSingle(APPID, $token, $message); + var_dump($ret); +} + + +/** + * 单推接口示例 + * @param $template: 推送的消息模板 + * @param $cid: 推送的客户端标识 + */ +function pushMessageToSingle($template, $cid){ + global $igt; + + //个推信息体 + $message = new IGtSingleMessage(); + $message->set_isOffline(true);//是否离线 + $message->set_offlineExpireTime(3600*12*1000);//离线时间 + $message->set_data($template);//设置推送消息类型 +// $message->set_PushNetWorkType(0);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 + //接收方 + $target = new IGtTarget(); + $target->set_appId(APPID); + $target->set_clientId($cid); +// $target->set_alias(Alias); + + try { + $rep = $igt->pushMessageToSingle($message, $target); + var_dump($rep); + }catch(RequestException $e){ + $requstId =e.getRequestId(); + $rep = $igt->pushMessageToSingle($message, $target, $requstId); + var_dump($rep); + } +} + + +/** + * 判断终端是否在线 + * @param $cid: 客户端标识 + */ +function isOnline($cid){ + global $igt; + + $status = $igt->getClientIdStatus(APPID,$cid); + + if(is_array($status)&&'Online'==$status['result']){ + return true; + } + return false; +} + +?> \ No newline at end of file diff --git a/push/UniPush/igetui/IGt.APNPayload.php b/push/UniPush/igetui/IGt.APNPayload.php new file mode 100644 index 0000000..4d0b718 --- /dev/null +++ b/push/UniPush/igetui/IGt.APNPayload.php @@ -0,0 +1,215 @@ +alertMsg != null) { + $msg = $this->alertMsg->get_alertMsg(); + if($msg != null) + { + $apsMap["alert"] = $msg; + } + } + if($this->autoBadge != null){ + $apsMap["autoBadge"] = $this->autoBadge; + }elseif($this->badge >= 0) { + $apsMap["badge"] = $this->badge; + } + if($this -> sound == null || $this->sound == '' ) + { + $apsMap["sound"] = 'default'; + }elseif($this->sound != $this->APN_SOUND_SILENCE) + { + $apsMap["sound"] = $this->sound; + } + + if (sizeof($apsMap) == 0) { + throw new Exception("format error"); + } + if ($this->contentAvailable > 0) { + $apsMap["content-available"] = $this->contentAvailable; + } + if ($this->category != null && $this->category != "") { + $apsMap["category"] = $this->category; + } + + $map = array(); + if(count($this->customMsg) > 0){ + foreach ($this->customMsg as $key => $value) { + $map[$key] = $value; + } + } + $map["aps"] = $apsMap; + if($this->apnsCollapseId != null){ + $map["apns-collapse-i"] = $this->apnsCollapseId; + } + if($this -> multiMedias != null && sizeof($this -> multiMedias) > 0) { + $map["_grinfo_"] = $this->check_multiMedias(); + } + if ($this->voicePlayType == 1){ + $map["_gvp_t_"] = 1; + }elseif($this->voicePlayType == 2 && !empty($this->voicePlayMessage)){ + $map["_gvp_t_"] = 2; + $map["_gvp_m_"] = $this->voicePlayMessage; + } + return json_encode($map); + } catch (Exception $e) { + throw new Exception("create apn payload error", -1, $e); + } + } + + public function add_customMsg($key, $value) + { + if ($key != null && $key != "" && $value != null) { + $this->customMsg[$key] = $value; + } + } + + function check_multiMedias() + { + if(sizeof($this -> multiMedias) > 3) { + throw new RuntimeException("MultiMedias size overlimit"); + } + + $needGeneRid = false; + $rids = array(); + for($i = 0; $i < sizeof($this -> multiMedias); $i++) { + $media = $this -> multiMedias[$i]; + if($media -> get_rid() == null) { + $needGeneRid = true; + } else { + $rids[$media -> get_rid()] = 0; + } + + if($media->get_type() == null || $media->get_url() == null) { + throw new RuntimeException("MultiMedia resType and resUrl can't be null"); + } + } + + if(sizeof($rids) != sizeof($this -> multiMedias)) { + $needGeneRid = true; + } + if($needGeneRid) { + for ($i = 0; $i < sizeof($this->multiMedias); $i++) { + $this->multiMedias[$i] -> set_rid("grid-" . $i); + } + } + + return $this -> multiMedias; + } + + function add_multiMedia($media) { + $this->multiMedias[] = $media; + return $this; + } + + function set_multiMedias($medias) { + $this->multiMedias = $medias; + return $this; + } +} +interface ApnMsg +{ + public function get_alertMsg(); +} + +class DictionaryAlertMsg implements ApnMsg{ + + var $title; + var $body; + var $titleLocKey; + var $titleLocArgs = array(); + var $actionLocKey; + var $locKey; + var $locArgs = array(); + var $launchImage; + var $subtitle; + var $subtitleLocKey; + var $subtitleLocArgs; + + public function get_alertMsg() { + + $alertMap = array(); + + if ($this->title != null && $this->title != "") { + $alertMap["title"] = $this->title; + } + if ($this->body != null && $this->body != "") { + $alertMap["body"] = $this->body; + } + if ($this->titleLocKey != null && $this->titleLocKey != "") { + $alertMap["title-loc-key"] = $this->titleLocKey; + } + if (sizeof($this->titleLocArgs) > 0) { + $alertMap["title-loc-args"] = $this->titleLocArgs; + } + if ($this->actionLocKey != null && $this->actionLocKey) { + $alertMap["action-loc-key"] = $this->actionLocKey; + } + if ($this->locKey != null && $this->locKey != "") { + $alertMap["loc-key"] = $this->locKey; + } + if (sizeof($this->locArgs) > 0) { + $alertMap["loc-args"] = $this->locArgs; + } + if ($this->launchImage != null && $this->launchImage != "") { + $alertMap["launch-image"] = $this->launchImage; + } + + if(count($alertMap) == 0) + { + return null; + } + + if ($this->subtitle != null && $this->subtitle != "") { + $alertMap["subtitle"] = $this->subtitle; + } + if (sizeof($this->subtitleLocArgs) > 0) { + $alertMap["subtitle-loc-args"] = $this->subtitleLocArgs; + } + if ($this->subtitleLocKey != null && $this->subtitleLocKey != "") { + $alertMap["subtitle-loc-key"] = $this->subtitleLocKey; + } + return $alertMap; + } +} + +class SimpleAlertMsg implements ApnMsg{ + var $alertMsg; + + public function get_alertMsg() { + return $this->alertMsg; + } +} +?> diff --git a/push/UniPush/igetui/IGt.AppMessage.php b/push/UniPush/igetui/IGt.AppMessage.php new file mode 100644 index 0000000..723aed3 --- /dev/null +++ b/push/UniPush/igetui/IGt.AppMessage.php @@ -0,0 +1,106 @@ +appIdList; + } + + function set_appIdList($appIdList) { + $this->appIdList = $appIdList; + } + + /** + * @deprecated deprecated since version 4.0.0.3 + */ + function get_phoneTypeList() { + return $this->phoneTypeList; + } + + /** + * @deprecated deprecated since version 4.0.0.3 + */ + function set_phoneTypeList($phoneTypeList) { + $this->phoneTypeList = $phoneTypeList; + } + + /** + * @deprecated deprecated since version 4.0.0.3 + */ + function get_provinceList() { + return $this->provinceList; + } + + /** + * @deprecated deprecated since version 4.0.0.3 + */ + function set_provinceList($provinceList) { + $this->provinceList = $provinceList; + } + + /** + * @deprecated deprecated since version 4.0.0.3 + */ + function get_tagList() { + return $this->tagList; + } + + /** + * @deprecated deprecated since version 4.0.0.3 + */ + function set_tagList($tagList) { + $this->tagList = $tagList; + } + + public function get_conditions() + { + return $this->conditions; + } + + /** + * @return mixed + */ + public function getPushTime() + { + return $this->pushTime; + } + + /** + * @param mixed $pushTime + */ + public function setPushTime($pushTime) + { + + $this->pushTime = $pushTime; + } + + + public function set_conditions($conditions) + { + $this->conditions = $conditions; + } + + function get_speed() + { + return $this->speed; + } + function set_speed($speed) + { + $this->speed=$speed; + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/IGt.ListMessage.php b/push/UniPush/igetui/IGt.ListMessage.php new file mode 100644 index 0000000..021b054 --- /dev/null +++ b/push/UniPush/igetui/IGt.ListMessage.php @@ -0,0 +1,9 @@ +isOffline; + } + function set_isOffline($isOffline) + { + return $this->isOffline = $isOffline; + } + function get_offlineExpireTime() + { + return $this->offlineExpireTime; + } + function set_offlineExpireTime($offlineExpireTime) + { + return $this->offlineExpireTime = $offlineExpireTime; + } + function get_pushNetWorkType() + { + return $this->pushNetWorkType; + } + function set_pushNetWorkType($pushNetWorkType) + { + return $this->pushNetWorkType = $pushNetWorkType; + } + function get_data() + { + return $this->data; + } + function set_data($data) + { + return $this->data = $data; + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/IGt.MultiMedia.php b/push/UniPush/igetui/IGt.MultiMedia.php new file mode 100644 index 0000000..a089f11 --- /dev/null +++ b/push/UniPush/igetui/IGt.MultiMedia.php @@ -0,0 +1,72 @@ +rid; + } + + function set_rid($rid) { + $this->rid = $rid; + return $this; + } + + function get_url() { + return $this->url; + } + + function set_url($url) { + $this->url = $url; + return$this; + } + + function get_type() { + return $this -> type; + } + + function set_type($type) { + $this -> type = $type; + return $this; + } + + function set_onlywifi($onlywifi) { + $this -> onlywifi = $onlywifi ? 1:0; + return $this; + } + + function get_onlywifi() { + return $this -> onlywifi; + } +} + +class MediaType { + const __default = self::pic; + + const pic = 1; + const audio = 2; + const video = 3; +} diff --git a/push/UniPush/igetui/IGt.Req.php b/push/UniPush/igetui/IGt.Req.php new file mode 100644 index 0000000..58888ee --- /dev/null +++ b/push/UniPush/igetui/IGt.Req.php @@ -0,0 +1,2362 @@ +fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBInt"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + } + function sign() + { + return $this->_get_value("1"); + } + function set_sign($value) + { + return $this->_set_value("1", $value); + } + function appkey() + { + return $this->_get_value("2"); + } + function set_appkey($value) + { + return $this->_set_value("2", $value); + } + function timestamp() + { + return $this->_get_value("3"); + } + function set_timestamp($value) + { + return $this->_set_value("3", $value); + } + function seqId() + { + return $this->_get_value("4"); + } + function set_seqId($value) + { + return $this->_set_value("4", $value); + } +} +class GtAuthResult_GtAuthResultCode extends PBEnum +{ + const successed = 0; + const failed_noSign = 1; + const failed_noAppkey = 2; + const failed_noTimestamp = 3; + const failed_AuthIllegal = 4; + const redirect = 5; +} +class GtAuthResult extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBInt"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + $this->fields["5"] = "PBString"; + $this->values["5"] = array(); + } + function code() + { + return $this->_get_value("1"); + } + function set_code($value) + { + return $this->_set_value("1", $value); + } + function redirectAddress() + { + return $this->_get_value("2"); + } + function set_redirectAddress($value) + { + return $this->_set_value("2", $value); + } + function seqId() + { + return $this->_get_value("3"); + } + function set_seqId($value) + { + return $this->_set_value("3", $value); + } + function info() + { + return $this->_get_value("4"); + } + function set_info($value) + { + return $this->_set_value("4", $value); + } + function appid($offset) + { + $v = $this->_get_arr_value("5", $offset); + return $v->get_value(); + } + function append_appid($value) + { + $v = $this->_add_arr_value("5"); + $v->set_value($value); + } + function set_appid($index, $value) + { + $v = new $this->fields["5"](); + $v->set_value($value); + $this->_set_arr_value("5", $index, $v); + } + function remove_last_appid() + { + $this->_remove_last_arr_value("5"); + } + function appid_size() + { + return $this->_get_arr_size("5"); + } +} +class ReqServList extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBInt"; + $this->values["2"] = ""; + } + function seqId() + { + return $this->_get_value("1"); + } + function set_seqId($value) + { + return $this->_set_value("1", $value); + } + function timestamp() + { + return $this->_get_value("2"); + } + function set_timestamp($value) + { + return $this->_set_value("2", $value); + } +} +class ReqServListResult_ReqServHostResultCode extends PBEnum +{ + const successed = 0; + const failed = 1; + const busy = 2; +} +class ReqServListResult extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBInt"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = array(); + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + } + function code() + { + return $this->_get_value("1"); + } + function set_code($value) + { + return $this->_set_value("1", $value); + } + function host($offset) + { + $v = $this->_get_arr_value("2", $offset); + return $v->get_value(); + } + function append_host($value) + { + $v = $this->_add_arr_value("2"); + $v->set_value($value); + } + function set_host($index, $value) + { + $v = new $this->fields["2"](); + $v->set_value($value); + $this->_set_arr_value("2", $index, $v); + } + function remove_last_host() + { + $this->_remove_last_arr_value("2"); + } + function host_size() + { + return $this->_get_arr_size("2"); + } + function seqId() + { + return $this->_get_value("3"); + } + function set_seqId($value) + { + return $this->_set_value("3", $value); + } +} +class PushResult_EPushResult extends PBEnum +{ + const successed_online = 0; + const successed_offline = 1; + const successed_ignore = 2; + const failed = 3; + const busy = 4; + const success_startBatch = 5; + const success_endBatch = 6; + const successed_async = 7; +} +class PushResult extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PushResult_EPushResult"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + $this->fields["5"] = "PBString"; + $this->values["5"] = ""; + $this->fields["6"] = "PBString"; + $this->values["6"] = ""; + $this->fields["7"] = "PBString"; + $this->values["7"] = ""; + $this->fields["8"] = "PBString"; + $this->values["8"] = ""; + } + function result() + { + return $this->_get_value("1"); + } + function set_result($value) + { + return $this->_set_value("1", $value); + } + function taskId() + { + return $this->_get_value("2"); + } + function set_taskId($value) + { + return $this->_set_value("2", $value); + } + function messageId() + { + return $this->_get_value("3"); + } + function set_messageId($value) + { + return $this->_set_value("3", $value); + } + function seqId() + { + return $this->_get_value("4"); + } + function set_seqId($value) + { + return $this->_set_value("4", $value); + } + function target() + { + return $this->_get_value("5"); + } + function set_target($value) + { + return $this->_set_value("5", $value); + } + function info() + { + return $this->_get_value("6"); + } + function set_info($value) + { + return $this->_set_value("6", $value); + } + function traceId() + { + return $this->_get_value("7"); + } + function set_traceId($value) + { + return $this->_set_value("7", $value); + } + function batchId() + { + return $this->_get_value("8"); + } + function set_batchId($value) + { + return $this->_set_value("8", $value); + } +} +class PushListResult extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PushResult"; + $this->values["1"] = array(); + } + function results($offset) + { + return $this->_get_arr_value("1", $offset); + } + function add_results() + { + return $this->_add_arr_value("1"); + } + function set_results($index, $value) + { + $this->_set_arr_value("1", $index, $value); + } + function remove_last_results() + { + $this->_remove_last_arr_value("1"); + } + function results_size() + { + return $this->_get_arr_size("1"); + } +} +class NotifyInfo_Type extends PBEnum +{ + const _payload = 0; + const _intent = 1; + const _url = 2; +} +class NotifyInfo extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + $this->fields["5"] = "PBString"; + $this->values["5"] = ""; + $this->fields["6"] = "NotifyInfo_Type"; + $this->values["6"] = ""; + $this->values["6"] = new NotifyInfo_Type(); + $this->values["6"]->value = NotifyInfo_Type::_payload; + $this->fields["7"] = "PBString"; + $this->values["7"] = ""; + } + function title() + { + return $this->_get_value("1"); + } + function set_title($value) + { + return $this->_set_value("1", $value); + } + function content() + { + return $this->_get_value("2"); + } + function set_content($value) + { + return $this->_set_value("2", $value); + } + function payload() + { + return $this->_get_value("3"); + } + function set_payload($value) + { + return $this->_set_value("3", $value); + } + function intent() + { + return $this->_get_value("4"); + } + function set_intent($value) + { + return $this->_set_value("4", $value); + } + function url() + { + return $this->_get_value("5"); + } + function set_url($value) + { + return $this->_set_value("5", $value); + } + function type() + { + return $this->_get_value("6"); + } + function set_type($value) + { + return $this->_set_value("6", $value); + } + function notifyId() + { + return $this->_get_value("7"); + } + function set_notifyId($value) + { + return $this->_set_value("7", $value); + } +} +class PushInfo extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + $this->fields["5"] = "PBString"; + $this->values["5"] = ""; + $this->fields["6"] = "PBString"; + $this->values["6"] = ""; + $this->fields["7"] = "PBString"; + $this->values["7"] = ""; + $this->fields["8"] = "PBString"; + $this->values["8"] = ""; + $this->fields["9"] = "PBString"; + $this->values["9"] = ""; + $this->fields["10"] = "PBInt"; + $this->values["10"] = ""; + $this->fields["11"] = "PBBool"; + $this->values["11"] = ""; + $this->fields["12"] = "PBString"; + $this->values["12"] = ""; + $this->fields["13"] = "PBBool"; + $this->values["13"] = ""; + $this->fields["14"] = "PBString"; + $this->values["14"] = ""; + $this->fields["15"] = "PBBool"; + $this->values["15"] = ""; + $this->fields["16"] = "NotifyInfo"; + $this->values["16"] = ""; + } + function message() + { + return $this->_get_value("1"); + } + function set_message($value) + { + return $this->_set_value("1", $value); + } + function actionKey() + { + return $this->_get_value("2"); + } + function set_actionKey($value) + { + return $this->_set_value("2", $value); + } + function sound() + { + return $this->_get_value("3"); + } + function set_sound($value) + { + return $this->_set_value("3", $value); + } + function badge() + { + return $this->_get_value("4"); + } + function set_badge($value) + { + return $this->_set_value("4", $value); + } + function payload() + { + return $this->_get_value("5"); + } + function set_payload($value) + { + return $this->_set_value("5", $value); + } + function locKey() + { + return $this->_get_value("6"); + } + function set_locKey($value) + { + return $this->_set_value("6", $value); + } + function locArgs() + { + return $this->_get_value("7"); + } + function set_locArgs($value) + { + return $this->_set_value("7", $value); + } + function actionLocKey() + { + return $this->_get_value("8"); + } + function set_actionLocKey($value) + { + return $this->_set_value("8", $value); + } + function launchImage() + { + return $this->_get_value("9"); + } + function set_launchImage($value) + { + return $this->_set_value("9", $value); + } + function contentAvailable() + { + return $this->_get_value("10"); + } + function set_contentAvailable($value) + { + return $this->_set_value("10", $value); + } + function invalidAPN() + { + return $this->_get_value("11"); + } + function set_invalidAPN($value) + { + return $this->_set_value("11", $value); + } + function apnJson() + { + return $this->_get_value("12"); + } + function set_apnJson($value) + { + return $this->_set_value("12", $value); + } + function invalidMPN() + { + return $this->_get_value("13"); + } + function set_invalidMPN($value) + { + return $this->_set_value("13", $value); + } + function mpnXml() + { + return $this->_get_value("14"); + } + function set_mpnXml($value) + { + return $this->_set_value("14", $value); + } + function validNotify() + { + return $this->_get_value("15"); + } + function set_validNotify($value) + { + return $this->_set_value("15", $value); + } + function notifyInfo() + { + return $this->_get_value("16"); + } + function set_notifyInfo($value) + { + return $this->_set_value("16", $value); + } +} +class Button extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBInt"; + $this->values["2"] = ""; + } + function text() + { + return $this->_get_value("1"); + } + function set_text($value) + { + return $this->_set_value("1", $value); + } + function next() + { + return $this->_get_value("2"); + } + function set_next($value) + { + return $this->_set_value("2", $value); + } +} +class AppStartUp extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + } + function android() + { + return $this->_get_value("1"); + } + function set_android($value) + { + return $this->_set_value("1", $value); + } + function symbia() + { + return $this->_get_value("2"); + } + function set_symbia($value) + { + return $this->_set_value("2", $value); + } + function ios() + { + return $this->_get_value("3"); + } + function set_ios($value) + { + return $this->_set_value("3", $value); + } +} +class Target extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + } + function appId() + { + return $this->_get_value("1"); + } + function set_appId($value) + { + return $this->_set_value("1", $value); + } + function clientId() + { + return $this->_get_value("2"); + } + function set_clientId($value) + { + return $this->_set_value("2", $value); + } + function alias() + { + return $this->_get_value("3"); + } + function set_alias($value) + { + return $this->_set_value("3", $value); + } +} +class SmsContentEntry extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + } + function key() + { + return $this->_get_value("1"); + } + function set_key($value) + { + return $this->_set_value("1", $value); + } + function value() + { + return $this->_get_value("2"); + } + function set_value($value) + { + return $this->_set_value("2", $value); + } +} +class SmsInfo extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "SmsContentEntry"; + $this->values["2"] = array(); + $this->fields["3"] = "PBInt"; + $this->values["3"] = ""; + $this->fields["4"] = "PBInt"; + $this->values["4"] = ""; + $this->fields["5"] = "PBBool"; + $this->values["5"] = ""; + $this->values["5"] = new PBBool(); + $this->values["5"]->value = false; + $this->fields["6"] = "PBString"; + $this->values["6"] = ""; + } + function smsTemplateId() + { + return $this->_get_value("1"); + } + function set_smsTemplateId($value) + { + return $this->_set_value("1", $value); + } + function smsContent($offset) + { + return $this->_get_arr_value("2", $offset); + } + function add_smsContent() + { + return $this->_add_arr_value("2"); + } + function set_smsContent($index, $value) + { + $this->_set_arr_value("2", $index, $value); + } + function remove_last_smsContent() + { + $this->_remove_last_arr_value("2"); + } + function smsContent_size() + { + return $this->_get_arr_size("2"); + } + function offlineSendtime() + { + return $this->_get_value("3"); + } + function set_offlineSendtime($value) + { + return $this->_set_value("3", $value); + } + function smsSendDuration() + { + return $this->_get_value("4"); + } + function set_smsSendDuration($value) + { + return $this->_set_value("4", $value); + } + function smsChecked() + { + return $this->_get_value("5"); + } + function set_smsChecked($value) + { + return $this->_set_value("5", $value); + } + function smsCheckedErrorMsg() + { + return $this->_get_value("6"); + } + function set_smsCheckedErrorMsg($value) + { + return $this->_set_value("6", $value); + } +} +class SMSStatus extends PBEnum +{ + const unread = 0; + const read = 1; +} +class InnerFiled_Type extends PBEnum +{ + const str = 0; + const int32 = 1; + const int64 = 2; + const floa = 3; + const doub = 4; + const bool = 5; +} +class InnerFiled extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "InnerFiled_Type"; + $this->values["3"] = ""; + } + function key() + { + return $this->_get_value("1"); + } + function set_key($value) + { + return $this->_set_value("1", $value); + } + function val() + { + return $this->_get_value("2"); + } + function set_val($value) + { + return $this->_set_value("2", $value); + } + function type() + { + return $this->_get_value("3"); + } + function set_type($value) + { + return $this->_set_value("3", $value); + } +} +class ActionChain_Type extends PBEnum +{ + const refer = 0; + const notification = 1; + const popup = 2; + const startapp = 3; + const startweb = 4; + const smsinbox = 5; + const checkapp = 6; + const eoa = 7; + const appdownload = 8; + const startsms = 9; + const httpproxy = 10; + const smsinbox2 = 11; + const mmsinbox2 = 12; + const popupweb = 13; + const dial = 14; + const reportbindapp = 15; + const reportaddphoneinfo = 16; + const reportapplist = 17; + const terminatetask = 18; + const reportapp = 19; + const enablelog = 20; + const disablelog = 21; + const uploadlog = 22; +} +class ActionChain extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBInt"; + $this->values["1"] = ""; + $this->fields["2"] = "ActionChain_Type"; + $this->values["2"] = ""; + $this->fields["3"] = "PBInt"; + $this->values["3"] = ""; + $this->fields["100"] = "PBString"; + $this->values["100"] = ""; + $this->fields["101"] = "PBString"; + $this->values["101"] = ""; + $this->fields["102"] = "PBString"; + $this->values["102"] = ""; + $this->fields["103"] = "PBString"; + $this->values["103"] = ""; + $this->fields["104"] = "PBBool"; + $this->values["104"] = ""; + $this->fields["105"] = "PBBool"; + $this->values["105"] = ""; + $this->fields["106"] = "PBBool"; + $this->values["106"] = ""; + $this->fields["107"] = "PBString"; + $this->values["107"] = ""; + $this->fields["120"] = "PBString"; + $this->values["120"] = ""; + $this->fields["121"] = "Button"; + $this->values["121"] = array(); + $this->fields["140"] = "PBString"; + $this->values["140"] = ""; + $this->fields["141"] = "AppStartUp"; + $this->values["141"] = ""; + $this->fields["142"] = "PBBool"; + $this->values["142"] = ""; + $this->fields["143"] = "PBInt"; + $this->values["143"] = ""; + $this->fields["160"] = "PBString"; + $this->values["160"] = ""; + $this->fields["161"] = "PBString"; + $this->values["161"] = ""; + $this->fields["162"] = "PBBool"; + $this->values["162"] = ""; + $this->values["162"] = new PBBool(); + $this->values["162"]->value = false; + $this->fields["180"] = "PBString"; + $this->values["180"] = ""; + $this->fields["181"] = "PBString"; + $this->values["181"] = ""; + $this->fields["182"] = "PBInt"; + $this->values["182"] = ""; + $this->fields["183"] = "SMSStatus"; + $this->values["183"] = ""; + $this->fields["200"] = "PBInt"; + $this->values["200"] = ""; + $this->fields["201"] = "PBInt"; + $this->values["201"] = ""; + $this->fields["220"] = "PBString"; + $this->values["220"] = ""; + $this->fields["223"] = "PBBool"; + $this->values["223"] = ""; + $this->fields["225"] = "PBBool"; + $this->values["225"] = ""; + $this->fields["226"] = "PBBool"; + $this->values["226"] = ""; + $this->fields["227"] = "PBBool"; + $this->values["227"] = ""; + $this->fields["241"] = "PBString"; + $this->values["241"] = ""; + $this->fields["242"] = "PBString"; + $this->values["242"] = ""; + $this->fields["260"] = "PBBool"; + $this->values["260"] = ""; + $this->fields["280"] = "PBString"; + $this->values["280"] = ""; + $this->fields["281"] = "PBString"; + $this->values["281"] = ""; + $this->fields["300"] = "PBBool"; + $this->values["300"] = ""; + $this->fields["320"] = "PBString"; + $this->values["320"] = ""; + $this->fields["340"] = "PBInt"; + $this->values["340"] = ""; + $this->fields["360"] = "PBString"; + $this->values["360"] = ""; + $this->fields["380"] = "PBString"; + $this->values["380"] = ""; + $this->fields["381"] = "InnerFiled"; + $this->values["381"] = array(); + $this->fields["382"] = "PBString"; + $this->values["382"] = ""; + $this->fields["383"] = "PBBool"; + $this->values["383"] = ""; + } + function actionId() + { + return $this->_get_value("1"); + } + function set_actionId($value) + { + return $this->_set_value("1", $value); + } + function type() + { + return $this->_get_value("2"); + } + function set_type($value) + { + return $this->_set_value("2", $value); + } + function next() + { + return $this->_get_value("3"); + } + function set_next($value) + { + return $this->_set_value("3", $value); + } + function logo() + { + return $this->_get_value("100"); + } + function set_logo($value) + { + return $this->_set_value("100", $value); + } + function logoURL() + { + return $this->_get_value("101"); + } + function set_logoURL($value) + { + return $this->_set_value("101", $value); + } + function title() + { + return $this->_get_value("102"); + } + function set_title($value) + { + return $this->_set_value("102", $value); + } + function text() + { + return $this->_get_value("103"); + } + function set_text($value) + { + return $this->_set_value("103", $value); + } + function clearable() + { + return $this->_get_value("104"); + } + function set_clearable($value) + { + return $this->_set_value("104", $value); + } + function ring() + { + return $this->_get_value("105"); + } + function set_ring($value) + { + return $this->_set_value("105", $value); + } + function buzz() + { + return $this->_get_value("106"); + } + function set_buzz($value) + { + return $this->_set_value("106", $value); + } + function bannerURL() + { + return $this->_get_value("107"); + } + function set_bannerURL($value) + { + return $this->_set_value("107", $value); + } + function img() + { + return $this->_get_value("120"); + } + function set_img($value) + { + return $this->_set_value("120", $value); + } + function buttons($offset) + { + return $this->_get_arr_value("121", $offset); + } + function add_buttons() + { + return $this->_add_arr_value("121"); + } + function set_buttons($index, $value) + { + $this->_set_arr_value("121", $index, $value); + } + function remove_last_buttons() + { + $this->_remove_last_arr_value("121"); + } + function buttons_size() + { + return $this->_get_arr_size("121"); + } + function appid() + { + return $this->_get_value("140"); + } + function set_appid($value) + { + return $this->_set_value("140", $value); + } + function appstartupid() + { + return $this->_get_value("141"); + } + function set_appstartupid($value) + { + return $this->_set_value("141", $value); + } + function autostart() + { + return $this->_get_value("142"); + } + function set_autostart($value) + { + return $this->_set_value("142", $value); + } + function failedAction() + { + return $this->_get_value("143"); + } + function set_failedAction($value) + { + return $this->_set_value("143", $value); + } + function url() + { + return $this->_get_value("160"); + } + function set_url($value) + { + return $this->_set_value("160", $value); + } + function withcid() + { + return $this->_get_value("161"); + } + function set_withcid($value) + { + return $this->_set_value("161", $value); + } + function is_withnettype() + { + return $this->_get_value("162"); + } + function set_is_withnettype($value) + { + return $this->_set_value("162", $value); + } + function address() + { + return $this->_get_value("180"); + } + function set_address($value) + { + return $this->_set_value("180", $value); + } + function content() + { + return $this->_get_value("181"); + } + function set_content($value) + { + return $this->_set_value("181", $value); + } + function ct() + { + return $this->_get_value("182"); + } + function set_ct($value) + { + return $this->_set_value("182", $value); + } + function flag() + { + return $this->_get_value("183"); + } + function set_flag($value) + { + return $this->_set_value("183", $value); + } + function successedAction() + { + return $this->_get_value("200"); + } + function set_successedAction($value) + { + return $this->_set_value("200", $value); + } + function uninstalledAction() + { + return $this->_get_value("201"); + } + function set_uninstalledAction($value) + { + return $this->_set_value("201", $value); + } + function name() + { + return $this->_get_value("220"); + } + function set_name($value) + { + return $this->_set_value("220", $value); + } + function autoInstall() + { + return $this->_get_value("223"); + } + function set_autoInstall($value) + { + return $this->_set_value("223", $value); + } + function wifiAutodownload() + { + return $this->_get_value("225"); + } + function set_wifiAutodownload($value) + { + return $this->_set_value("225", $value); + } + function forceDownload() + { + return $this->_get_value("226"); + } + function set_forceDownload($value) + { + return $this->_set_value("226", $value); + } + function showProgress() + { + return $this->_get_value("227"); + } + function set_showProgress($value) + { + return $this->_set_value("227", $value); + } + function post() + { + return $this->_get_value("241"); + } + function set_post($value) + { + return $this->_set_value("241", $value); + } + function headers() + { + return $this->_get_value("242"); + } + function set_headers($value) + { + return $this->_set_value("242", $value); + } + function groupable() + { + return $this->_get_value("260"); + } + function set_groupable($value) + { + return $this->_set_value("260", $value); + } + function mmsTitle() + { + return $this->_get_value("280"); + } + function set_mmsTitle($value) + { + return $this->_set_value("280", $value); + } + function mmsURL() + { + return $this->_get_value("281"); + } + function set_mmsURL($value) + { + return $this->_set_value("281", $value); + } + function preload() + { + return $this->_get_value("300"); + } + function set_preload($value) + { + return $this->_set_value("300", $value); + } + function taskid() + { + return $this->_get_value("320"); + } + function set_taskid($value) + { + return $this->_set_value("320", $value); + } + function duration() + { + return $this->_get_value("340"); + } + function set_duration($value) + { + return $this->_set_value("340", $value); + } + function date() + { + return $this->_get_value("360"); + } + function set_date($value) + { + return $this->_set_value("360", $value); + } + function stype() + { + return $this->_get_value("380"); + } + function set_stype($value) + { + return $this->_set_value("380", $value); + } + function field($offset) + { + return $this->_get_arr_value("381", $offset); + } + function add_field() + { + return $this->_add_arr_value("381"); + } + function set_field($index, $value) + { + $this->_set_arr_value("381", $index, $value); + } + function remove_last_field() + { + $this->_remove_last_arr_value("381"); + } + function field_size() + { + return $this->_get_arr_size("381"); + } + function notifyid() + { + return $this->_get_value("382"); + } + function set_notifyid($value) + { + return $this->_set_value("382", $value); + } + function force() + { + return $this->_get_value("383"); + } + function set_force($value) + { + return $this->_set_value("383", $value); + } +} +class Transparent extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + $this->fields["5"] = "PBString"; + $this->values["5"] = ""; + $this->fields["6"] = "PBString"; + $this->values["6"] = ""; + $this->fields["7"] = "PushInfo"; + $this->values["7"] = ""; + $this->fields["8"] = "ActionChain"; + $this->values["8"] = array(); + $this->fields["9"] = "PBString"; + $this->values["9"] = array(); + $this->fields["10"] = "PBInt"; + $this->values["10"] = ""; + $this->fields["11"] = "PBString"; + $this->values["11"] = ""; + $this->fields["12"] = "SmsInfo"; + $this->values["12"] = ""; + } + function id() + { + return $this->_get_value("1"); + } + function set_id($value) + { + return $this->_set_value("1", $value); + } + function action() + { + return $this->_get_value("2"); + } + function set_action($value) + { + return $this->_set_value("2", $value); + } + function taskId() + { + return $this->_get_value("3"); + } + function set_taskId($value) + { + return $this->_set_value("3", $value); + } + function appKey() + { + return $this->_get_value("4"); + } + function set_appKey($value) + { + return $this->_set_value("4", $value); + } + function appId() + { + return $this->_get_value("5"); + } + function set_appId($value) + { + return $this->_set_value("5", $value); + } + function messageId() + { + return $this->_get_value("6"); + } + function set_messageId($value) + { + return $this->_set_value("6", $value); + } + function pushInfo() + { + return $this->_get_value("7"); + } + function set_pushInfo($value) + { + return $this->_set_value("7", $value); + } + function actionChain($offset) + { + return $this->_get_arr_value("8", $offset); + } + function add_actionChain() + { + return $this->_add_arr_value("8"); + } + function set_actionChain($index, $value) + { + $this->_set_arr_value("8", $index, $value); + } + function remove_last_actionChain() + { + $this->_remove_last_arr_value("8"); + } + function actionChain_size() + { + return $this->_get_arr_size("8"); + } + function condition($offset) + { + $v = $this->_get_arr_value("9", $offset); + return $v->get_value(); + } + function append_condition($value) + { + $v = $this->_add_arr_value("9"); + $v->set_value($value); + } + function set_condition($index, $value) + { + $v = new $this->fields["9"](); + $v->set_value($value); + $this->_set_arr_value("9", $index, $v); + } + function remove_last_condition() + { + $this->_remove_last_arr_value("9"); + } + function condition_size() + { + return $this->_get_arr_size("9"); + } + function templateId() + { + return $this->_get_value("10"); + } + function set_templateId($value) + { + return $this->_set_value("10", $value); + } + function taskGroupId() + { + return $this->_get_value("11"); + } + function set_taskGroupId($value) + { + return $this->_set_value("11", $value); + } + function smsInfo() + { + return $this->_get_value("12"); + } + function set_smsInfo($value) + { + return $this->_set_value("12", $value); + } +} +class OSMessage extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["2"] = "PBBool"; + $this->values["2"] = ""; + $this->fields["3"] = "PBInt"; + $this->values["3"] = ""; + $this->fields["4"] = "Transparent"; + $this->values["4"] = ""; + $this->fields["5"] = "PBString"; + $this->values["5"] = ""; + $this->fields["6"] = "PBInt"; + $this->values["6"] = ""; + $this->fields["7"] = "PBInt"; + $this->values["7"] = ""; + $this->fields["8"] = "PBInt"; + $this->values["8"] = ""; + } + function isOffline() + { + return $this->_get_value("2"); + } + function set_isOffline($value) + { + return $this->_set_value("2", $value); + } + function offlineExpireTime() + { + return $this->_get_value("3"); + } + function set_offlineExpireTime($value) + { + return $this->_set_value("3", $value); + } + function transparent() + { + return $this->_get_value("4"); + } + function set_transparent($value) + { + return $this->_set_value("4", $value); + } + function extraData() + { + return $this->_get_value("5"); + } + function set_extraData($value) + { + return $this->_set_value("5", $value); + } + function msgType() + { + return $this->_get_value("6"); + } + function set_msgType($value) + { + return $this->_set_value("6", $value); + } + function msgTraceFlag() + { + return $this->_get_value("7"); + } + function set_msgTraceFlag($value) + { + return $this->_set_value("7", $value); + } + function priority() + { + return $this->_get_value("8"); + } + function set_priority($value) + { + return $this->_set_value("8", $value); + } +} +class PushOSSingleMessage extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "OSMessage"; + $this->values["2"] = ""; + $this->fields["3"] = "Target"; + $this->values["3"] = ""; + } + function seqId() + { + return $this->_get_value("1"); + } + function set_seqId($value) + { + return $this->_set_value("1", $value); + } + function message() + { + return $this->_get_value("2"); + } + function set_message($value) + { + return $this->_set_value("2", $value); + } + function target() + { + return $this->_get_value("3"); + } + function set_target($value) + { + return $this->_set_value("3", $value); + } +} +class MMPMessage extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["2"] = "Transparent"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBInt"; + $this->values["4"] = ""; + $this->fields["5"] = "PBInt"; + $this->values["5"] = ""; + $this->fields["6"] = "PBInt"; + $this->values["6"] = ""; + $this->fields["7"] = "PBBool"; + $this->values["7"] = ""; + $this->values["7"] = new PBBool(); + $this->values["7"]->value = true; + $this->fields["8"] = "PBInt"; + $this->values["8"] = ""; + $this->fields["9"] = "PBString"; + $this->values["9"] = ""; + $this->fields["10"] = "PBBool"; + $this->values["10"] = ""; + $this->values["10"] = new PBBool(); + $this->values["10"]->value = true; + } + function transparent() + { + return $this->_get_value("2"); + } + function set_transparent($value) + { + return $this->_set_value("2", $value); + } + function extraData() + { + return $this->_get_value("3"); + } + function set_extraData($value) + { + return $this->_set_value("3", $value); + } + function msgType() + { + return $this->_get_value("4"); + } + function set_msgType($value) + { + return $this->_set_value("4", $value); + } + function msgTraceFlag() + { + return $this->_get_value("5"); + } + function set_msgTraceFlag($value) + { + return $this->_set_value("5", $value); + } + function msgOfflineExpire() + { + return $this->_get_value("6"); + } + function set_msgOfflineExpire($value) + { + return $this->_set_value("6", $value); + } + function isOffline() + { + return $this->_get_value("7"); + } + function set_isOffline($value) + { + return $this->_set_value("7", $value); + } + function priority() + { + return $this->_get_value("8"); + } + function set_priority($value) + { + return $this->_set_value("8", $value); + } + function cdnUrl() + { + return $this->_get_value("9"); + } + function set_cdnUrl($value) + { + return $this->_set_value("9", $value); + } + function isSync() + { + return $this->_get_value("10"); + } + function set_isSync($value) + { + return $this->_set_value("10", $value); + } +} +class PushMMPSingleMessage extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "MMPMessage"; + $this->values["2"] = ""; + $this->fields["3"] = "Target"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + } + function seqId() + { + return $this->_get_value("1"); + } + function set_seqId($value) + { + return $this->_set_value("1", $value); + } + function message() + { + return $this->_get_value("2"); + } + function set_message($value) + { + return $this->_set_value("2", $value); + } + function target() + { + return $this->_get_value("3"); + } + function set_target($value) + { + return $this->_set_value("3", $value); + } + function requestId() + { + return $this->_get_value("4"); + } + function set_requestId($value) + { + return $this->_set_value("4", $value); + } +} +class PushMMPSingleBatchMessage extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PushMMPSingleMessage"; + $this->values["2"] = array(); + $this->fields["3"] = "PBBool"; + $this->values["3"] = ""; + $this->values["3"] = new PBBool(); + $this->values["3"]->value = true; + } + function batchId() + { + return $this->_get_value("1"); + } + function set_batchId($value) + { + return $this->_set_value("1", $value); + } + function batchItem($offset) + { + return $this->_get_arr_value("2", $offset); + } + function add_batchItem() + { + return $this->_add_arr_value("2"); + } + function set_batchItem($index, $value) + { + $this->_set_arr_value("2", $index, $value); + } + function remove_last_batchItem() + { + $this->_remove_last_arr_value("2"); + } + function batchItem_size() + { + return $this->_get_arr_size("2"); + } + function isSync() + { + return $this->_get_value("3"); + } + function set_isSync($value) + { + return $this->_set_value("3", $value); + } +} +class StartMMPBatchTask extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "MMPMessage"; + $this->values["1"] = ""; + $this->fields["2"] = "PBInt"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + } + function message() + { + return $this->_get_value("1"); + } + function set_message($value) + { + return $this->_set_value("1", $value); + } + function expire() + { + return $this->_get_value("2"); + } + function set_expire($value) + { + return $this->_set_value("2", $value); + } + function seqId() + { + return $this->_get_value("3"); + } + function set_seqId($value) + { + return $this->_set_value("3", $value); + } + function taskGroupName() + { + return $this->_get_value("4"); + } + function set_taskGroupName($value) + { + return $this->_set_value("4", $value); + } +} +class StartOSBatchTask extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "OSMessage"; + $this->values["1"] = ""; + $this->fields["2"] = "PBInt"; + $this->values["2"] = ""; + } + function message() + { + return $this->_get_value("1"); + } + function set_message($value) + { + return $this->_set_value("1", $value); + } + function expire() + { + return $this->_get_value("2"); + } + function set_expire($value) + { + return $this->_set_value("2", $value); + } +} +class SingleBatchItem extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBInt"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + } + function seqId() + { + return $this->_get_value("1"); + } + function set_seqId($value) + { + return $this->_set_value("1", $value); + } + function data() + { + return $this->_get_value("2"); + } + function set_data($value) + { + return $this->_set_value("2", $value); + } +} +class SingleBatchRequest extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "SingleBatchItem"; + $this->values["2"] = array(); + } + function batchId() + { + return $this->_get_value("1"); + } + function set_batchId($value) + { + return $this->_set_value("1", $value); + } + function batchItem($offset) + { + return $this->_get_arr_value("2", $offset); + } + function add_batchItem() + { + return $this->_add_arr_value("2"); + } + function set_batchItem($index, $value) + { + $this->_set_arr_value("2", $index, $value); + } + function remove_last_batchItem() + { + $this->_remove_last_arr_value("2"); + } + function batchItem_size() + { + return $this->_get_arr_size("2"); + } +} +class PushListMessage extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "Target"; + $this->values["3"] = array(); + } + function seqId() + { + return $this->_get_value("1"); + } + function set_seqId($value) + { + return $this->_set_value("1", $value); + } + function taskId() + { + return $this->_get_value("2"); + } + function set_taskId($value) + { + return $this->_set_value("2", $value); + } + function targets($offset) + { + return $this->_get_arr_value("3", $offset); + } + function add_targets() + { + return $this->_add_arr_value("3"); + } + function set_targets($index, $value) + { + $this->_set_arr_value("3", $index, $value); + } + function remove_last_targets() + { + $this->_remove_last_arr_value("3"); + } + function targets_size() + { + return $this->_get_arr_size("3"); + } +} +class EndBatchTask extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + } + function taskId() + { + return $this->_get_value("1"); + } + function set_taskId($value) + { + return $this->_set_value("1", $value); + } + function seqId() + { + return $this->_get_value("2"); + } + function set_seqId($value) + { + return $this->_set_value("2", $value); + } +} +class StopBatchTask extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + } + function taskId() + { + return $this->_get_value("1"); + } + function set_taskId($value) + { + return $this->_set_value("1", $value); + } + function appkey() + { + return $this->_get_value("2"); + } + function set_appkey($value) + { + return $this->_set_value("2", $value); + } + function appId() + { + return $this->_get_value("3"); + } + function set_appId($value) + { + return $this->_set_value("3", $value); + } + function seqId() + { + return $this->_get_value("4"); + } + function set_seqId($value) + { + return $this->_set_value("4", $value); + } +} +class StopBatchTaskResult extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBBool"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + } + function result() + { + return $this->_get_value("1"); + } + function set_result($value) + { + return $this->_set_value("1", $value); + } + function info() + { + return $this->_get_value("2"); + } + function set_info($value) + { + return $this->_set_value("2", $value); + } + function seqId() + { + return $this->_get_value("3"); + } + function set_seqId($value) + { + return $this->_set_value("3", $value); + } +} +class PushMMPAppMessage extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "MMPMessage"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = array(); + $this->fields["3"] = "PBString"; + $this->values["3"] = array(); + $this->fields["4"] = "PBString"; + $this->values["4"] = array(); + $this->fields["5"] = "PBString"; + $this->values["5"] = ""; + } + function message() + { + return $this->_get_value("1"); + } + function set_message($value) + { + return $this->_set_value("1", $value); + } + function appIdList($offset) + { + $v = $this->_get_arr_value("2", $offset); + return $v->get_value(); + } + function append_appIdList($value) + { + $v = $this->_add_arr_value("2"); + $v->set_value($value); + } + function set_appIdList($index, $value) + { + $v = new $this->fields["2"](); + $v->set_value($value); + $this->_set_arr_value("2", $index, $v); + } + function remove_last_appIdList() + { + $this->_remove_last_arr_value("2"); + } + function appIdList_size() + { + return $this->_get_arr_size("2"); + } + function phoneTypeList($offset) + { + $v = $this->_get_arr_value("3", $offset); + return $v->get_value(); + } + function append_phoneTypeList($value) + { + $v = $this->_add_arr_value("3"); + $v->set_value($value); + } + function set_phoneTypeList($index, $value) + { + $v = new $this->fields["3"](); + $v->set_value($value); + $this->_set_arr_value("3", $index, $v); + } + function remove_last_phoneTypeList() + { + $this->_remove_last_arr_value("3"); + } + function phoneTypeList_size() + { + return $this->_get_arr_size("3"); + } + function provinceList($offset) + { + $v = $this->_get_arr_value("4", $offset); + return $v->get_value(); + } + function append_provinceList($value) + { + $v = $this->_add_arr_value("4"); + $v->set_value($value); + } + function set_provinceList($index, $value) + { + $v = new $this->fields["4"](); + $v->set_value($value); + $this->_set_arr_value("4", $index, $v); + } + function remove_last_provinceList() + { + $this->_remove_last_arr_value("4"); + } + function provinceList_size() + { + return $this->_get_arr_size("4"); + } + function seqId() + { + return $this->_get_value("5"); + } + function set_seqId($value) + { + return $this->_set_value("5", $value); + } +} +class ServerNotify_NotifyType extends PBEnum +{ + const normal = 0; + const serverListChanged = 1; + const exception = 2; +} +class ServerNotify extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "ServerNotify_NotifyType"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + $this->fields["3"] = "PBString"; + $this->values["3"] = ""; + $this->fields["4"] = "PBString"; + $this->values["4"] = ""; + } + function type() + { + return $this->_get_value("1"); + } + function set_type($value) + { + return $this->_set_value("1", $value); + } + function info() + { + return $this->_get_value("2"); + } + function set_info($value) + { + return $this->_set_value("2", $value); + } + function extradata() + { + return $this->_get_value("3"); + } + function set_extradata($value) + { + return $this->_set_value("3", $value); + } + function seqId() + { + return $this->_get_value("4"); + } + function set_seqId($value) + { + return $this->_set_value("4", $value); + } +} +class ServerNotifyResult extends PBMessage +{ + var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; + public function __construct($reader=null) + { + parent::__construct($reader); + $this->fields["1"] = "PBString"; + $this->values["1"] = ""; + $this->fields["2"] = "PBString"; + $this->values["2"] = ""; + } + function seqId() + { + return $this->_get_value("1"); + } + function set_seqId($value) + { + return $this->_set_value("1", $value); + } + function info() + { + return $this->_get_value("2"); + } + function set_info($value) + { + return $this->_set_value("2", $value); + } +} +?> \ No newline at end of file diff --git a/push/UniPush/igetui/IGt.SingleMessage.php b/push/UniPush/igetui/IGt.SingleMessage.php new file mode 100644 index 0000000..2a8cd0d --- /dev/null +++ b/push/UniPush/igetui/IGt.SingleMessage.php @@ -0,0 +1,9 @@ +appIdList; + } + + function set_appIdList($appIdList) { + $this->appIdList = $appIdList; + } + + function get_tag() { + return $this->tag; + } + + function set_tag($tag) { + $this->tag = $tag; + } + + function get_speed() + { + return $this->speed; + } + function set_speed($speed) + { + $this->speed=$speed; + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/IGt.Target.php b/push/UniPush/igetui/IGt.Target.php new file mode 100644 index 0000000..cd0d516 --- /dev/null +++ b/push/UniPush/igetui/IGt.Target.php @@ -0,0 +1,40 @@ +appId; + } + function set_appId($appId) + { + return $this->appId = $appId; + } + function get_clientId() + { + return $this->clientId; + } + function set_clientId($clientId) + { + return $this->clientId = $clientId; + } + function set_alias($alias) + { + return $this->alias = $alias; + } + function get_alias() + { + return $this->alias; + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/template/IGt.APNTemplate.php b/push/UniPush/igetui/template/IGt.APNTemplate.php new file mode 100644 index 0000000..6a2f297 --- /dev/null +++ b/push/UniPush/igetui/template/IGt.APNTemplate.php @@ -0,0 +1,11 @@ +set_templateId($this->getTemplateId()); + $transparent->set_id(''); + $transparent->set_messageId(''); + $transparent->set_taskId(''); + $transparent->set_action('pushmessage'); + $transparent->set_pushInfo($this->get_pushInfo()); + $transparent->set_appId($this->appId); + $transparent->set_appKey($this->appkey); + if($this->smsInfo != null){ + $transparent->set_smsInfo($this->smsInfo); + } + + $actionChainList = $this->getActionChain(); + + foreach ($actionChainList as $index => $actionChain) { + $transparent->add_actionChain(); + $transparent->set_actionChain($index, $actionChain); + } + + $transparent->append_condition($this->get_durcondition()); + + return $transparent->SerializeToString(); + + //return $transparent->condition(0); + } + + function getActionChain() + { + return $list = array(); + } + + function get_durcondition() + { + if ($this->duration == null || $this->duration == '') + { + return ""; + } + return "duration=" . $this->duration; + } + + function get_duration() + { + return $this->duration; + } + + function set_duration($begin, $end) + + { + date_default_timezone_set('asia/shanghai'); + /* //for test + var_dump(date("Y-m-d H:i:s",strtotime($begin))); + var_dump(date("Y-m-d H:i:s",strtotime($end))); + */ + $ss = (string)strtotime($begin) * 1000; + $e = (string)strtotime($end) * 1000; + if ($ss <= 0 || $e <= 0) + throw new Exception("DateFormat: yyyy-MM-dd HH:mm:ss"); + if ($ss > $e) + throw new Exception("startTime should be smaller than endTime"); + + $this->duration = $ss . "-" . $e; + + } + + function get_transmissionContent() + { + return null; + } + + function get_pushType() + { + return null; + } + + function get_actionChain() + { + return null; + } + + function get_pushInfo() + { + if ($this->pushInfo == null) { + $this->pushInfo = new PushInfo(); + $this->pushInfo->set_invalidAPN(true); + $this->pushInfo->set_invalidMPN(true); + } + + return $this->pushInfo; + } + + function setSmsInfo($smsMessage){ + + if($smsMessage == null){ + throw new RuntimeException("smsInfo cannot be empty"); + } else { + $smsTemplateId = $smsMessage->getSmsTemplateId(); + $smsContent = $smsMessage->getSmsContent(); + $offlineSendtime = $smsMessage->getOfflineSendtime(); + $smsSendDuration = 0; + if ($smsTemplateId != null || !empty($smsTemplateId)) { + if ($offlineSendtime == null) { + throw new RuntimeException("offlineSendtime cannot be empty"); + } else { + $build = new SmsInfo(); + $build->set_smsChecked(false); + $build->set_smsTemplateId($smsTemplateId); + $build->set_offlineSendtime($offlineSendtime); + if ($smsMessage->getisApplink()) { + + if ($smsContent['url'] != null) { + throw new RuntimeException("SmsContent cann not contains key about url"); + } + $smsContentEntry = new SmsContentEntry(); + $smsContentEntry->set_key("applinkIdentification"); + $smsContentEntry->set_value("1"); + $build->set_smsContent("applinkIdentification",$smsContentEntry); + $payload = $smsMessage->getPayload(); + + if ($payload != null && !empty($payload)) { + $smsContentEntry = new SmsContentEntry(); + $smsContentEntry->set_key("url"); + $smsContentEntry->set_value($smsMessage->getUrl() . "?n=" . $payload . "&p="); + $build->set_smsContent("url",$smsContentEntry); + } else { + $smsContentEntry = new SmsContentEntry(); + $smsContentEntry->set_key("url"); + $smsContentEntry->set_value($smsMessage->getUrl() . "?p="); + $build->set_smsContent("url",$smsContentEntry); + } + } + if ($smsContent != null) { + foreach ($smsContent as $key => $value) { + if ($key == null || empty($key) || $value == null) { + throw new RuntimeException("smsContent entry cannot be null"); + } else { + $smsContentEntry = new SmsContentEntry(); + $smsContentEntry->set_key($key); + $smsContentEntry->set_value($value); + $build->set_smsContent($key,$smsContentEntry); + } + } + } + if ($smsSendDuration != null) { + $build->smsSendDuration($smsSendDuration); + } + $this->smsInfo = $build; + } + } + else { + throw new RuntimeException("smsTemplateId cannot be empty"); + } + + } + + + } + function set_pushInfo($actionLocKey, $badge, $message, $sound, $payload, $locKey, $locArgs, $launchImage, $contentAvailable = 0) + { + $apn = new IGtAPNPayload(); + + $alertMsg = new DictionaryAlertMsg(); + if ($actionLocKey != null && $actionLocKey != '') + { + $alertMsg->actionLocKey = $actionLocKey; + } + if ($message != null && $message != '') + { + $alertMsg->body = $message; + } + if ($locKey != null && $locKey != '') + { + $alertMsg->locKey = $locKey; + } + if ($locArgs != null && $locArgs != '') + { + array_push($alertMsg->locArgs, $locArgs); + } + + if ($launchImage != null && $launchImage != '') + { + $alertMsg->launchImage = $launchImage; + } + $apn->alertMsg = $alertMsg; + + if ($badge != null ) + { + $apn->badge = $badge; + } + if ($sound != null && $sound != '') + { + $apn->sound = $sound; + } + if ($contentAvailable != null ) + { + $apn->contentAvailable = $contentAvailable; + } + if ($payload != null && $payload != '') + { + $apn->add_customMsg("payload", $payload); + } + $this->set_apnInfo($apn); + } + + function set_apnInfo($payload) + { + if ($payload == null) { + return; + } + $payload = $payload->get_payload(); + if ($payload == null || $payload == "") { + return; + } + $len = strlen($payload); + if ($len > IGtAPNPayload::$PAYLOAD_MAX_BYTES) { + throw new Exception("APN payload length overlength (" . $len . ">" . IGtAPNPayload::$PAYLOAD_MAX_BYTES . ")"); + } + $pushInfo = $this->get_pushInfo(); + $pushInfo->set_apnJson($payload); + $pushInfo->set_invalidAPN(false); + } + + function set_appId($appId) + { + $this->appId = $appId; + } + + function set_appkey($appkey) + { + $this->appkey = $appkey; + } + + function abslength($str) + { + if (empty($str)) { + return 0; + } + if (function_exists('mb_strlen')) { + return mb_strlen($str, 'utf-8'); + } else { + preg_match_all("/./u", $str, $ar); + return count($ar[0]); + } + } + + function getTemplateId() { + if($this instanceof IGtNotificationTemplate) { + return 0; + } + if($this instanceof IGtLinkTemplate) { + return 1; + } + if($this instanceof IGtNotyPopLoadTemplate) { + return 2; + } + if($this instanceof IGtTransmissionTemplate) { + return 4; + } + if($this instanceof IGtAPNTemplate) { + return 5; + } + + if($this instanceof IGtStartActivityTemplate) { + return 7; + } + return -1; + } + + +} \ No newline at end of file diff --git a/push/UniPush/igetui/template/IGt.LinkTemplate.php b/push/UniPush/igetui/template/IGt.LinkTemplate.php new file mode 100644 index 0000000..1980e8e --- /dev/null +++ b/push/UniPush/igetui/template/IGt.LinkTemplate.php @@ -0,0 +1,187 @@ +set_actionId(1); + $actionChain1->set_type(ActionChain_Type::refer); + $actionChain1->set_next(10000); + + //通知 + $actionChain2 = new ActionChain(); + $actionChain2->set_actionId(10000); + $actionChain2->set_type(ActionChain_Type::mmsinbox2); + $actionChain2->set_stype("notification"); + + $f_text = new InnerFiled(); + $f_text->set_key("text"); + $f_text->set_val($this->text); + $f_text->set_type(InnerFiled_Type::str); + $actionChain2->set_field(0,$f_text); + + $f_title = new InnerFiled(); + $f_title->set_key("title"); + $f_title->set_val($this->title); + $f_title->set_type(InnerFiled_Type::str); + $actionChain2->set_field(1,$f_title); + + $f_logo = new InnerFiled(); + $f_logo->set_key("logo"); + $f_logo->set_val($this->logo); + $f_logo->set_type(InnerFiled_Type::str); + $actionChain2->set_field(2,$f_logo); + + $f_logoURL = new InnerFiled(); + $f_logoURL->set_key("logo_url"); + $f_logoURL->set_val($this->logoURL); + $f_logoURL->set_type(InnerFiled_Type::str); + $actionChain2->set_field(3,$f_logoURL); + + $f_notifyStyle = new InnerFiled(); + $f_notifyStyle->set_key("notifyStyle"); + $f_notifyStyle->set_val(strval($this->notifyStyle)); + $f_notifyStyle->set_type(InnerFiled_Type::str); + $actionChain2->set_field(4,$f_notifyStyle); + + $f_isRing = new InnerFiled(); + $f_isRing->set_key("is_noring"); + $f_isRing->set_val(!$this->isRing ? "true" : "false"); + $f_isRing->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(5,$f_isRing); + + $f_isVibrate = new InnerFiled(); + $f_isVibrate->set_key("is_novibrate"); + $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false"); + $f_isVibrate->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(6,$f_isVibrate); + + $f_isClearable = new InnerFiled(); + $f_isClearable->set_key("is_noclear"); + $f_isClearable->set_val(!$this->isClearable ? "true" : "false"); + $f_isClearable->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(7,$f_isClearable); + + $actionChain2->set_next(10010); + + $actionChain3 = new ActionChain(); + $actionChain3->set_actionId(10010); + $actionChain3->set_type(ActionChain_Type::refer); + $actionChain3->set_next(10020); + + + //goto + $actionChain3 = new ActionChain(); + $actionChain3->set_actionId(10010); + $actionChain3->set_type(ActionChain_Type::refer); + $actionChain3->set_next(10040); + + + //启动web + $actionChain4 = new ActionChain(); + $actionChain4->set_actionId(10040); + $actionChain4->set_type(ActionChain_Type::startweb); + $actionChain4->set_url($this->url); + $actionChain4->set_next(100); + + + //结束 + $actionChain5 = new ActionChain(); + $actionChain5->set_actionId(100); + $actionChain5->set_type(ActionChain_Type::eoa); + + array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5); + + return $actionChains; + } + + function get_pushType() { + return 'LinkMsg'; + } + + function set_text($text) { + $this->text = $text; + } + + function set_title($title) { + $this->title = $title; + } + + function set_logo($logo) { + $this->logo = $logo; + } + + function set_logoURL($logoURL) { + $this->logoURL = $logoURL; + } + + function set_url($url) { + $this->url = $url; + } + + function set_isRing($isRing) { + $this->isRing = $isRing; + } + + function set_isVibrate($isVibrate) { + $this->isVibrate = $isVibrate; + } + + function set_isClearable($isClearable) { + $this->isClearable = $isClearable; + } + + function set_notifyStyle($notifyStyle) { + if($notifyStyle != 1){ + $this->notifyStyle = 0; + } else { + $this->notifyStyle = 1; + } + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/template/IGt.NotificationTemplate.php b/push/UniPush/igetui/template/IGt.NotificationTemplate.php new file mode 100644 index 0000000..4355663 --- /dev/null +++ b/push/UniPush/igetui/template/IGt.NotificationTemplate.php @@ -0,0 +1,168 @@ +set_actionId(1); + $actionChain1->set_type(ActionChain_Type::refer); + $actionChain1->set_next(10000); + + //通知 + $actionChain2 = new ActionChain(); + $actionChain2->set_actionId(10000); + $actionChain2->set_type(ActionChain_Type::mmsinbox2); + $actionChain2->set_stype("notification"); + + $f_text = new InnerFiled(); + $f_text->set_key("text"); + $f_text->set_val($this->text); + $f_text->set_type(InnerFiled_Type::str); + $actionChain2->set_field(0,$f_text); + + $f_title = new InnerFiled(); + $f_title->set_key("title"); + $f_title->set_val($this->title); + $f_title->set_type(InnerFiled_Type::str); + $actionChain2->set_field(1,$f_title); + + $f_logo = new InnerFiled(); + $f_logo->set_key("logo"); + $f_logo->set_val($this->logo); + $f_logo->set_type(InnerFiled_Type::str); + $actionChain2->set_field(2,$f_logo); + + $f_logoURL = new InnerFiled(); + $f_logoURL->set_key("logo_url"); + $f_logoURL->set_val($this->logoURL); + $f_logoURL->set_type(InnerFiled_Type::str); + $actionChain2->set_field(3,$f_logoURL); + + $f_notifyStyle = new InnerFiled(); + $f_notifyStyle->set_key("notifyStyle"); + $f_notifyStyle->set_val(strval($this->notifyStyle)); + $f_notifyStyle->set_type(InnerFiled_Type::str); + $actionChain2->set_field(4,$f_notifyStyle); + + $f_isRing = new InnerFiled(); + $f_isRing->set_key("is_noring"); + $f_isRing->set_val(!$this->isRing ? "true" : "false"); + $f_isRing->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(5,$f_isRing); + + $f_isVibrate = new InnerFiled(); + $f_isVibrate->set_key("is_novibrate"); + $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false"); + $f_isVibrate->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(6,$f_isVibrate); + + $f_isClearable = new InnerFiled(); + $f_isClearable->set_key("is_noclear"); + $f_isClearable->set_val(!$this->isClearable ? "true" : "false"); + $f_isClearable->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(7,$f_isClearable); + + $actionChain2->set_next(10010); + + //goto + $actionChain3 = new ActionChain(); + $actionChain3->set_actionId(10010); + $actionChain3->set_type(ActionChain_Type::refer); + $actionChain3->set_next(10030); + + + //appStartUp + $appStartUp = new AppStartUp(); + $appStartUp->set_android(""); + $appStartUp->set_symbia(""); + $appStartUp->set_ios(""); + + //启动app + $actionChain4 = new ActionChain(); + $actionChain4->set_actionId(10030); + $actionChain4->set_type(ActionChain_Type::startapp); + $actionChain4->set_appid(""); + $actionChain4->set_autostart($this->transmissionType == '1'? true : false); + $actionChain4->set_appstartupid($appStartUp); + $actionChain4->set_failedAction(100); + $actionChain4->set_next(100); + + + //结束 + $actionChain5 = new ActionChain(); + $actionChain5->set_actionId(100); + $actionChain5->set_type(ActionChain_Type::eoa); + + array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5); + + return $actionChains; + } + + function get_transmissionContent() { + return $this->transmissionContent; + } + + function get_pushType() { + return 'NotifyMsg'; + } + + function set_text($text) { + $this->text = $text; + } + + function set_title($title) { + $this->title = $title; + } + + function set_logo($logo) { + $this->logo = $logo; + } + + function set_logoURL($logoURL) { + $this->logoURL = $logoURL; + } + + function set_transmissionType($transmissionType) { + $this->transmissionType = $transmissionType; + } + + function set_isRing($isRing) { + $this->isRing = $isRing; + } + + function set_isVibrate($isVibrate) { + $this->isVibrate = $isVibrate; + } + + function set_isClearable($isClearable) { + $this->isClearable = $isClearable; + } + + function set_transmissionContent($transmissionContent) { + $this->transmissionContent = $transmissionContent; + } + + function set_notifyStyle($notifyStyle) { + if($notifyStyle != 1){ + $this->notifyStyle = 0; + } else { + $this->notifyStyle = 1; + } + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/template/IGt.NotyPopLoadTemplate.php b/push/UniPush/igetui/template/IGt.NotyPopLoadTemplate.php new file mode 100644 index 0000000..cfa345c --- /dev/null +++ b/push/UniPush/igetui/template/IGt.NotyPopLoadTemplate.php @@ -0,0 +1,263 @@ +set_actionId(1); + $actionChain1->set_type(ActionChain_Type::refer); + $actionChain1->set_next(10000); + //通知 + $actionChain2 = new ActionChain(); + $actionChain2->set_actionId(10000); + $actionChain2->set_type(ActionChain_Type::mmsinbox2); + $actionChain2->set_stype("notification"); + + $f_text = new InnerFiled(); + $f_text->set_key("text"); + $f_text->set_val($this->notyContent); + $f_text->set_type(InnerFiled_Type::str); + $actionChain2->set_field(0,$f_text); + + $f_title = new InnerFiled(); + $f_title->set_key("title"); + $f_title->set_val($this->notyTitle); + $f_title->set_type(InnerFiled_Type::str); + $actionChain2->set_field(1,$f_title); + + $f_logo = new InnerFiled(); + $f_logo->set_key("logo"); + $f_logo->set_val($this->notyIcon); + $f_logo->set_type(InnerFiled_Type::str); + $actionChain2->set_field(2,$f_logo); + + $f_logoURL = new InnerFiled(); + $f_logoURL->set_key("logo_url"); + $f_logoURL->set_val($this->logoURL); + $f_logoURL->set_type(InnerFiled_Type::str); + $actionChain2->set_field(3,$f_logoURL); + + $f_notifyStyle = new InnerFiled(); + $f_notifyStyle->set_key("notifyStyle"); + $f_notifyStyle->set_val(strval($this->notifyStyle)); + $f_notifyStyle->set_type(InnerFiled_Type::str); + $actionChain2->set_field(4,$f_notifyStyle); + + $f_isRing = new InnerFiled(); + $f_isRing->set_key("is_noring"); + $f_isRing->set_val(!$this->isBelled ? "true" : "false"); + $f_isRing->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(5,$f_isRing); + + $f_isVibrate = new InnerFiled(); + $f_isVibrate->set_key("is_novibrate"); + $f_isVibrate->set_val(!$this->isVibrationed ? "true" : "false"); + $f_isVibrate->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(6,$f_isVibrate); + + $f_isClearable = new InnerFiled(); + $f_isClearable->set_key("is_noclear"); + $f_isClearable->set_val(!$this->isCleared ? "true" : "false"); + $f_isClearable->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(7,$f_isClearable); + + $actionChain2->set_next(10010); + + $actionChain3 = new ActionChain(); + $actionChain3->set_actionId(10010); + $actionChain3->set_type(ActionChain_Type::refer); + $actionChain3->set_next(10020); + + //弹框按钮 + $button1 = new Button(); + $button1->set_text($this->popButton1); + $button1->set_next(10050); + $button2 = new Button(); + $button2->set_text($this->popButton2); + $button2->set_next(100); + + //弹框 + $actionChain4 = new ActionChain(); + $actionChain4->set_actionId(10020); + $actionChain4->set_type(ActionChain_Type::popup); + $actionChain4->set_title($this->popTitle); + $actionChain4->set_text($this->popContent); + $actionChain4->set_img($this->popImage); + $actionChain4->set_buttons(0,$button1); + $actionChain4->set_buttons(1,$button2); + $actionChain4->set_next(6); + + //下载 + //appstartupid + $appStartUp = new AppStartUp(); + $appStartUp->set_android($this->androidMark); + $appStartUp->set_Ios($this->iosMark); + $appStartUp->set_symbia($this->symbianMark); + $actionChain5 = new ActionChain(); + $actionChain5->set_actionId(10050); + $actionChain5->set_type(ActionChain_Type::appdownload); + $actionChain5->set_name($this->loadTitle); + $actionChain5->set_url($this->loadUrl); + $actionChain5->set_logo($this->loadIcon); + $actionChain5->set_autoInstall($this->isAutoInstall); + $actionChain5->set_autostart($this->isActived); + $actionChain5->set_appstartupid($appStartUp); + $actionChain5->set_next(6); + + $actionChain6 = new ActionChain(); + $actionChain6->set_actionId(100); + $actionChain6->set_type(ActionChain_Type::eoa); + + array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5,$actionChain6); + return $actionChains; + } + + function set_notyIcon($notyIcon) { + $this->notyIcon = $notyIcon; + } + function set_notyTitle($notyTitle) { + $this->notyTitle = $notyTitle; + } + function set_logoURL($logoURL) { + $this->logoURL = $logoURL; + } + function set_notyContent($notyContent) { + $this->notyContent = $notyContent; + } + function set_isCleared($isCleared) { + $this->isCleared = $isCleared; + } + function set_isBelled($isBelled) { + $this->isBelled = $isBelled; + } + function set_isVibrationed($isVibrationed) { + $this->isVibrationed = $isVibrationed; + } + function set_popTitle($popTitle) { + $this->popTitle = $popTitle; + } + function set_popContent($popContent) { + $this->popContent = $popContent; + } + function set_popImage($popImage) { + $this->popImage = $popImage; + } + function set_popButton1($popButton1) { + $this->popButton1 = $popButton1; + } + function set_popButton2($popButton2) { + $this->popButton2 = $popButton2; + } + function set_loadIcon($loadIcon) { + $this->loadIcon = $loadIcon; + } + function set_loadTitle($loadTitle) { + $this->loadTitle = $loadTitle; + } + function set_loadUrl($loadUrl) { + $this->loadUrl = $loadUrl; + } + function set_isAutoInstall($isAutoInstall) { + $this->isAutoInstall = $isAutoInstall; + } + function set_isActived($isActived) { + $this->isActived = $isActived; + } + function set_symbianMark($symbianMark){ + $this->symbianMark = $symbianMark; + } + function set_androidMark($androidMark){ + $this->androidMark = $androidMark; + } + function set_iosMark($iosMark){ + $this->iosMark = $iosMark; + } + function get_pushType(){ + return "NotyPopLoadTemplate"; + } + + function set_notifyStyle($notifyStyle) { + if($notifyStyle != 1){ + $this->notifyStyle = 0; + } else { + $this->notifyStyle = 1; + } + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/template/IGt.StartActivityTemplate.php b/push/UniPush/igetui/template/IGt.StartActivityTemplate.php new file mode 100644 index 0000000..4d37ea2 --- /dev/null +++ b/push/UniPush/igetui/template/IGt.StartActivityTemplate.php @@ -0,0 +1,203 @@ + set_actionId(1); + $actionChain1->set_type(ActionChain_Type::refer); + $actionChain1->set_next(10000); + + $actionChain2 = new ActionChain(); + $actionChain2->set_actionId(10000); + $actionChain2->set_type(ActionChain_Type::mmsinbox2); + $actionChain2->set_stype("notification"); + + $f_text = new InnerFiled(); + $f_text->set_key("text"); + $f_text->set_val($this->text); + $f_text->set_type(InnerFiled_Type::str); + $actionChain2->set_field(0,$f_text); + + $f_title = new InnerFiled(); + $f_title->set_key("title"); + $f_title->set_val($this->title); + $f_title->set_type(InnerFiled_Type::str); + $actionChain2->set_field(1,$f_title); + + $f_logo = new InnerFiled(); + $f_logo->set_key("logo"); + $f_logo->set_val($this->logo); + $f_logo->set_type(InnerFiled_Type::str); + $actionChain2->set_field(2,$f_logo); + + $f_logoURL = new InnerFiled(); + $f_logoURL->set_key("logo_url"); + $f_logoURL->set_val($this->logoURL); + $f_logoURL->set_type(InnerFiled_Type::str); + $actionChain2->set_field(3,$f_logoURL); + + $f_notifyStyle = new InnerFiled(); + $f_notifyStyle->set_key("notifyStyle"); + $f_notifyStyle->set_val(strval($this->notifyStyle)); + $f_notifyStyle->set_type(InnerFiled_Type::str); + $actionChain2->set_field(4,$f_notifyStyle); + + $f_isRing = new InnerFiled(); + $f_isRing->set_key("is_noring"); + $f_isRing->set_val(!$this->isRing ? "true" : "false"); + $f_isRing->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(5,$f_isRing); + + $f_isVibrate = new InnerFiled(); + $f_isVibrate->set_key("is_novibrate"); + $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false"); + $f_isVibrate->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(6,$f_isVibrate); + + $f_isClearable = new InnerFiled(); + $f_isClearable->set_key("is_noclear"); + $f_isClearable->set_val(!$this->isClearable ? "true" : "false"); + $f_isClearable->set_type(InnerFiled_Type::bool); + $actionChain2->set_field(7,$f_isClearable); + + $actionChain2->set_next(10010); + + $actionChain3 = new ActionChain(); + $actionChain3->set_actionId(10010); + $actionChain3->set_type(ActionChain_Type::refer); + $actionChain3->set_next(11220); + + $actionChain4 = new ActionChain(); + $actionChain4->set_actionId(11220); + $actionChain4->set_type(ActionChain_Type::mmsinbox2); + $actionChain4->set_stype("startmyactivity"); + + $f_uri = new InnerFiled(); + $f_uri->set_key("uri"); + $f_uri->set_val($this->get_intent()); + $f_uri->set_type(InnerFiled_Type::str); + $actionChain4->set_field(0,$f_uri); + + $f_doFailed = new InnerFiled(); + $f_doFailed->set_key("do_failed"); + $f_doFailed->set_val("100"); + $f_doFailed->set_type(InnerFiled_Type::str); + $actionChain4->set_field(1,$f_doFailed); + + $actionChain4->set_next(100); + + $actionChain5 = new ActionChain(); + $actionChain5->set_actionId(100); + $actionChain5->set_type(ActionChain_Type::eoa); + + array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5); + + return $actionChains; + } + + function get_pushType() { + return 'StartActivity'; + } + + function set_intent($intent){ + if(strlen($intent) > GTConfig::getStartActivityIntentLimit()){ + throw new Exception("intent size overlimit " . GTConfig::getStartActivityIntentLimit()); + } + //不符合intent的格式要求 + if(!preg_match(self::pattern,$intent)){ + throw new Exception("intent format err,should start with \"intent:#Intent;\",end \"with ;end\" "); + } + + $this -> intent = $intent; + + } + + function get_intent(){ + return $this->intent==null?"":$this->intent; + } + + /** + * @param mixed $text + */ + public function set_text($text) + { + $this->text = $text; + } + + /** + * @param mixed $title + */ + public function set_title($title) + { + $this->title = $title; + } + + /** + * @param mixed $logo + */ + public function set_logo($logo) + { + $this->logo = $logo; + } + + /** + * @param mixed $logoURL + */ + public function set_logoURL($logoURL) + { + $this->logoURL = $logoURL; + } + + /** + * @param mixed $notifyStyle + */ + public function set_notifyStyle($notifyStyle) + { + $this->notifyStyle = $notifyStyle; + } + + /** + * @param mixed $isRing + */ + public function set_isRing($isRing) + { + $this->isRing = $isRing; + } + + /** + * @param mixed $isVibrate + */ + public function set_isVibrate($isVibrate) + { + $this->isVibrate = $isVibrate; + } + + /** + * @param mixed $isClearable + */ + public function set_isClearable($isClearable) + { + $this->isClearable = $isClearable; + } + +} \ No newline at end of file diff --git a/push/UniPush/igetui/template/IGt.TransmissionTemplate.php b/push/UniPush/igetui/template/IGt.TransmissionTemplate.php new file mode 100644 index 0000000..a3c287b --- /dev/null +++ b/push/UniPush/igetui/template/IGt.TransmissionTemplate.php @@ -0,0 +1,100 @@ +set_actionId(1); + $actionChain1->set_type(ActionChain_Type::refer); + $actionChain1->set_next(10030); + + //appStartUp + $appStartUp = new AppStartUp(); + $appStartUp->set_android(""); + $appStartUp->set_symbia(""); + $appStartUp->set_ios(""); + + //启动app + $actionChain2 = new ActionChain(); + $actionChain2->set_actionId(10030); + $actionChain2->set_type(ActionChain_Type::startapp); + $actionChain2->set_appid(""); + $actionChain2->set_autostart($this->transmissionType == '1'? true : false); + $actionChain2->set_appstartupid($appStartUp); + $actionChain2->set_failedAction(100); + $actionChain2->set_next(100); + + //结束 + $actionChain3 = new ActionChain(); + $actionChain3->set_actionId(100); + $actionChain3->set_type(ActionChain_Type::eoa); + + + array_push($actionChains, $actionChain1,$actionChain2,$actionChain3); + + return $actionChains; + } + + function get_transmissionContent() { + return $this->transmissionContent; + } + + function get_pushType() { + return 'TransmissionMsg'; + } + + + function set_transmissionType($transmissionType) { + $this->transmissionType = $transmissionType; + } + + function set_transmissionContent($transmissionContent) { + $this->transmissionContent = $transmissionContent; + } + + function set3rdNotifyInfo($notify) { + if ($notify->get_title() == null || $notify -> get_content() == null) { + throw new Exception("notify title or content cannot be null"); + } + + $notifyInfo = new NotifyInfo(); + $notifyInfo -> set_title($notify -> get_title()); + $notifyInfo -> set_content($notify -> get_content()); + + //不指定类型,只发简单通知 ,php 中 空串、false、0、null的值都是相等的,type的枚举值都是大于等于0的 + if($notify -> get_type() > -1){ + $notifyInfo ->set_type($notify -> get_type()); + if($notify -> get_payload() != null){ + $notifyInfo -> set_payload($notify -> get_payload()); + } + + if($notify -> get_intent() != null){ + if(strlen($notify -> get_intent()) > GTConfig::getNotifyIntentLimit()){ + throw new Exception("intent size overlimit " . GTConfig::getNotifyIntentLimit()); + } + //不符合intent的格式要求 + if(!preg_match(self::pattern,$notify -> get_intent())){ + throw new Exception("intent format err,should start with \"intent:#Intent;\",end \"with ;end\" "); + } + + $notifyInfo -> set_intent($notify -> get_intent()); + } + + if($notify -> get_url() != null){ + $notifyInfo ->set_url($notify -> get_url()); + } + } + + $pushInfo = $this-> get_pushInfo(); + $pushInfo -> set_notifyInfo($notifyInfo); + $pushInfo -> set_validNotify(true); + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/template/notify/IGt.Notify.php b/push/UniPush/igetui/template/notify/IGt.Notify.php new file mode 100644 index 0000000..5d1a24b --- /dev/null +++ b/push/UniPush/igetui/template/notify/IGt.Notify.php @@ -0,0 +1,137 @@ +title; + } + + /** + * @param mixed $title + */ + public function set_title($title) + { + $this->title = $title; + } + + /** + * @return mixed + */ + public function get_content() + { + return $this->content; + } + + /** + * @param mixed $content + */ + public function set_content($content) + { + $this->content = $content; + } + + /** + * @return mixed + */ + public function get_payload() + { + return $this->payload; + } + + /** + * @param mixed $payload + */ + public function set_payload($payload) + { + $this->payload = $payload; + } + + /** + * @return mixed + */ + public function get_url() + { + return $this->url; + } + + /** + * @param mixed $url + */ + public function set_url($url) + { + $this->url = $url; + } + + /** + * @return mixed + */ + public function get_intent() + { + return $this->intent; + } + + /** + * @param mixed $intent + */ + public function set_intent($intent) + { + $this->intent = $intent; + } + + /** + * @return mixed + */ + public function get_type() + { + return $this->type; + } + + /** + * @param mixed $type + */ + public function set_type($type) + { + $this->type = $type; + } +} diff --git a/push/UniPush/igetui/template/notify/SmsMessage.php b/push/UniPush/igetui/template/notify/SmsMessage.php new file mode 100644 index 0000000..9a234cb --- /dev/null +++ b/push/UniPush/igetui/template/notify/SmsMessage.php @@ -0,0 +1,124 @@ +smsTemplateId; + } + + /** + * @param mixed $smsTemplateId + */ + public function setSmsTemplateId($smsTemplateId) + { + $this->smsTemplateId = $smsTemplateId; + } + + /** + * @return mixed + */ + public function getSmsContent() + { + return $this->smsContent; + } + + /** + * @param mixed $smsContent + */ + public function setSmsContent($smsContent) + { + $this->smsContent = $smsContent; + } + + /** + * @return mixed + */ + public function getOfflineSendtime() + { + return $this->offlineSendtime; + } + + /** + * @param mixed $offlineSendtime + */ + public function setOfflineSendtime($offlineSendtime) + { + $this->offlineSendtime = $offlineSendtime; + } + + + /** + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param mixed $url + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * @return mixed + */ + public function getisApplink() + { + return $this->isApplink; + } + + /** + * @param mixed $isApplink + */ + public function setIsApplink($isApplink) + { + $this->isApplink = $isApplink; + } + + /** + * @return mixed + */ + public function getPayload() + { + return $this->payload; + } + + /** + * @param mixed $payload + */ + public function setPayload($payload) + { + $this->payload = $payload; + }//自定义字段 + +} + +?> \ No newline at end of file diff --git a/push/UniPush/igetui/utils/ApiUrlRespectUtils.php b/push/UniPush/igetui/utils/ApiUrlRespectUtils.php new file mode 100644 index 0000000..01a1ab0 --- /dev/null +++ b/push/UniPush/igetui/utils/ApiUrlRespectUtils.php @@ -0,0 +1,55 @@ + $diff) + { + $mint=$diff; + $s_url=$hosts[$i]; + } + } + return $s_url; + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/utils/ApnsUtils.php b/push/UniPush/igetui/utils/ApnsUtils.php new file mode 100644 index 0000000..d3adaa0 --- /dev/null +++ b/push/UniPush/igetui/utils/ApnsUtils.php @@ -0,0 +1,301 @@ + 0) { + // loc-key + $pb->setAlertLocKey(($locKey)); + // loc-args + if ($locArgs != null && strlen($locArgs) > 0) { + $pb->setAlertLocArgs(explode(',',($locArgs))); + } + $isValid = true; + } + + // body + if ($message != null && strlen($message) > 0) { + $pb->setAlertBody(($message)); + $isValid = true; + } + + // action-loc-key + if ($actionLocKey!=null && strlen($actionLocKey) > 0) { + $pb->setAlertActionLocKey($actionLocKey); + } + + // launch-image + if ($launchImage!=null && strlen($launchImage) > 0) { + $pb->setAlertLaunchImage($launchImage); + } + + // badge + $badgeNum = -1; + if(is_numeric($badge)){ + $badgeNum = (int)$badge; + } + if ($badgeNum >= 0) { + $pb->setBadge($badgeNum); + $isValid = true; + } + + // sound + if ($sound != null && strlen($sound) > 0) { + $pb->setSound($sound); + } else { + $pb->setSound("default"); + } + + //contentAvailable + if ($contentAvailable == 1) { + $pb->setContentAvailable(1); + $isValid = true; + } + + // payload + if ($payload != null && strlen($payload) > 0) { + $pb->addParam("payload", ($payload)); + } + + if($isValid == false){ + throw new Exception("one of the params(locKey,message,badge) must not be null or contentAvailable must be 1"); + } + $json = $pb->toString(); + if($json == null){ + throw new Exception("payload json is null"); + } + return $json; + } +} + +Class Payload +{ + var $APS = "aps"; + var $params; + var $alert; + var $badge; + var $sound = ""; + + var $alertBody; + var $alertActionLocKey; + var $alertLocKey; + var $alertLocArgs; + var $alertLaunchImage; + var $contentAvailable; + + function getParams() + { + return $this->params; + } + + function setParams($params) + { + $this->params = $params; + } + + function addParam($key, $obj) + { + if ($this->params == null) { + $this->params = array(); + } + if ($this->APS == strtolower($key)) { + throw new Exception("the key can't be aps"); + } + $this->params[$key] = $obj; + } + + function getAlert() + { + return $this->alert; + } + + function setAlert($alert) + { + $this->alert = $alert; + } + + function getBadge() + { + return $this->badge; + } + + function setBadge($badge) + { + $this->badge = $badge; + } + + function getSound() + { + return $this->sound; + } + + function setSound($sound) + { + $this->sound = $sound; + } + + function getAlertBody() + { + return $this->alertBody; + } + + function setAlertBody($alertBody) + { + $this->alertBody = $alertBody; + } + + function getAlertActionLocKey() + { + return $this->alertActionLocKey; + } + + function setAlertActionLocKey($alertActionLocKey) + { + $this->alertActionLocKey = $alertActionLocKey; + } + + function getAlertLocKey() + { + return $this->alertLocKey; + } + + function setAlertLocKey($alertLocKey) + { + $this->alertLocKey = $alertLocKey; + } + + function getAlertLaunchImage() + { + return $this->alertLaunchImage; + } + + function setAlertLaunchImage($alertLaunchImage) + { + $this->alertLaunchImage = $alertLaunchImage; + } + + function getAlertLocArgs() + { + return $this->alertLocArgs; + } + + function setAlertLocArgs($alertLocArgs) + { + $this->alertLocArgs = $alertLocArgs; + } + + function getContentAvailable() + { + return $this->contentAvailable; + } + + function setContentAvailable($contentAvailable) + { + $this->contentAvailable = $contentAvailable; + } + + function putIntoJson($key, $value, $obj) + { + if ($value != null) { + $obj[$key] = $value; + } + return $obj; + } + + function toString() + { + $object = array(); + $apsObj = array(); + if ($this->getAlert() != null) { + $apsObj["alert"] = urlencode($this->getAlert()); + } else { + if ($this->getAlertBody() != null || $this->getAlertLocKey() != null) { + $alertObj = array(); + $alertObj = $this->putIntoJson("body", ($this->getAlertBody()), $alertObj); + $alertObj = $this->putIntoJson("action-loc-key", ($this->getAlertActionLocKey()), $alertObj); + $alertObj = $this->putIntoJson("loc-key", ($this->getAlertLocKey()), $alertObj); + $alertObj = $this->putIntoJson("launch-image", ($this->getAlertLaunchImage()), $alertObj); + if ($this->getAlertLocArgs() != null) { + $array = array(); + foreach ($this->getAlertLocArgs() as $str) { + array_push($array, ($str)); + } + $alertObj["loc-args"] = $array; + } + $apsObj["alert"] = $alertObj; + } + } + if ($this->getBadge() != null) { + $apsObj["badge"] = $this->getBadge(); + } + // 判断是否静音 + if ("com.gexin.ios.silence" != ($this->getSound())) { + $apsObj = $this->putIntoJson("sound", ($this->getSound()), $apsObj); + } + if($this->getContentAvailable() == 1){ + $apsObj["content-available"]=1; + } + $object[$this->APS] = $apsObj; + if ($this->getParams() != null) { + foreach ($this->getParams() as $key => $value) { + $object[($key)] = ($value); + } + } + return Util::json_encode($object); + } +} + +class Util +{ + static function json_encode($input){ + // 从 PHP 5.4.0 起, 增加了这个选项. + if(defined('JSON_UNESCAPED_UNICODE')){ + return json_encode($input, JSON_UNESCAPED_UNICODE); + } + if(is_string($input)){ + $text = $input; + $text = str_replace("\\", "\\\\", $text); + //$text = str_replace('/', "\\/", $text); + $text = str_replace('"', "\\".'"', $text); + $text = str_replace("\b", "\\b", $text); + $text = str_replace("\t", "\\t", $text); + $text = str_replace("\n", "\\n", $text); + $text = str_replace("\f", "\\f", $text); + $text = str_replace("\r", "\\r", $text); + //$text = str_replace("\u", "\\u", $text); + return '"' . $text . '"'; + } else if(is_array($input) || is_object($input)) { + $arr = array(); + $is_obj = is_object($input) || (array_keys($input) !== range(0, count($input) - 1)); + foreach($input as $k=>$v){ + if($is_obj){ + $arr[] = self::json_encode($k) . ':' . self::json_encode($v); + }else{ + $arr[] = self::json_encode($v); + } + } + if($is_obj){ + return '{' . join(',', $arr) . '}'; + }else{ + return '[' . join(',', $arr) . ']'; + } + }else{ + return $input . ''; + } + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/utils/AppConditions.php b/push/UniPush/igetui/utils/AppConditions.php new file mode 100644 index 0000000..3e62198 --- /dev/null +++ b/push/UniPush/igetui/utils/AppConditions.php @@ -0,0 +1,53 @@ + condition[] = $item; + return $this; + } + function addCondition2($key, $values) { + return $this->addCondition3($key, $values, 0); + } + + function getCondition() { + return $this->condition; + } + } + ?> \ No newline at end of file diff --git a/push/UniPush/igetui/utils/GTConfig.php b/push/UniPush/igetui/utils/GTConfig.php new file mode 100644 index 0000000..f12e912 --- /dev/null +++ b/push/UniPush/igetui/utils/GTConfig.php @@ -0,0 +1,164 @@ += 462850) { + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 30000); + curl_setopt($curl, CURLOPT_NOSIGNAL, 1); + } + // 通过代理访问接口需要在此处配置代理 + // curl_setopt ($curl, CURLOPT_PROXY, GTConfig::getHttpProxyIp()); + // curl_setopt($curl,CURLOPT_PROXYPORT,GTConfig::getHttpProxyPort()); + // curl_setopt($curl, CURLOPT_PROXYUSERNAME, GTConfig::getHttpProxyUserName()); + // curl_setopt($curl, CURLOPT_PROXYPASSWORD, GTConfig::getHttpProxyPasswd()); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // return don't print + curl_setopt($curl, CURLOPT_TIMEOUT, 30); //设置超时时间 + curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect + curl_setopt($curl, CURLOPT_MAXREDIRS, 7); //HTTp定向级别 + //curl_setopt($curl, CURLOPT_PROXY, '10.241.32.57:3128');//修改为服务器环境的代理地址 + //请求失败有3次重试机会 + $result = HttpManager::exeBySetTimes(3, $curl); + //curl_close($curl); + return $result; + } + + public static function httpHead($url) + { + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); + curl_setopt($curl, CURLOPT_USERAGENT, 'GeTui PHP/1.0'); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD'); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, GTConfig::getHttpConnectionTimeOut()); + curl_setopt($curl, CURLOPT_TIMEOUT_MS, GTConfig::getHttpSoTimeOut()); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($curl, CURLOPT_NOBODY, 1); + $header = array("Content-Type:text/html;charset=UTF-8"); + curl_setopt($curl, CURLOPT_HTTPHEADER,$header); + + $curl_version = curl_version(); + if ($curl_version['version_number'] >= 462850) { + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 30000); + curl_setopt($curl, CURLOPT_NOSIGNAL, 1); + } + + //通过代理访问接口需要在此处配置代理 + // curl_setopt ($curl, CURLOPT_PROXY, GTConfig::getHttpProxyIp()); + // curl_setopt($curl,CURLOPT_PROXYPORT,GTConfig::getHttpProxyPort()); + // curl_setopt($curl, CURLOPT_PROXYUSERNAME, GTConfig::getHttpProxyUserName()); + // curl_setopt($curl, CURLOPT_PROXYPASSWORD, GTConfig::getHttpProxyPasswd()); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // return don't print + curl_setopt($curl, CURLOPT_TIMEOUT, 30); //设置超时时间 + curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect + curl_setopt($curl, CURLOPT_MAXREDIRS, 7); //HTTp定向级别 + //curl_setopt($curl, CURLOPT_PROXY, '10.241.32.57:3128');//修改为服务器环境的代理地址 + //请求失败有3次重试机会 + $result = HttpManager::exeBySetTimes(3, $curl); + + curl_close($curl); + return $result; + } + + public static function httpPostJson($url, $params, $gzip) + { + if(!isset($params["version"])) + { + $params["version"] = GTConfig::getSDKVersion(); + } + $action = $params["action"]; + $data = json_encode($params); + $result = null; + try { + $resp = HttpManager::httpPost($url, $data, $gzip, $action); + //LogUtils::debug("发送请求 post:{$data} return:{$resp}"); + $result = json_decode($resp, true); + return $result; + } catch (Exception $e) { + throw new RequestException($params["requestId"],"httpPost:[".$url."] [" .$data." ] [ ".$result."]:",$e); + } + } + + private static function exeBySetTimes($count, $curl) + { + $result = curl_exec($curl); + $info = curl_getinfo($curl); + $code = $info["http_code"]; + + if (curl_errno($curl) != 0 && $code != 200) { + LogUtils::debug("request errno: ".curl_errno($curl).",url:".$info["url"]); + $count--; + if ($count > 0) { + $result = HttpManager::exeBySetTimes($count, $curl); + } + } + return $result; + } +} \ No newline at end of file diff --git a/push/UniPush/igetui/utils/LangUtils.php b/push/UniPush/igetui/utils/LangUtils.php new file mode 100644 index 0000000..b6e9c79 --- /dev/null +++ b/push/UniPush/igetui/utils/LangUtils.php @@ -0,0 +1,33 @@ + + + + + + 消息推送 - UniPush + + + + +
+

HBuilderX真机运行基座unipush推送

+
+

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
终端标识: + + />
+
+

+ [必填],个推平台设备标识ClientId(cid),接收推送消息终端设备的唯一标识,在5+ API中可通过plus.push.getClientInfo().clientid获取。 +

+

标题: + + /> +
+

+ [必填],推送通知的标题,显示在系统消息中心。 +

+
内容:
+

+ [必填],推送消息的内容,显示在系统消息中心。 +

+
数据:
+

+ [选填],客户端可获取此数据内容,根据数据内容处理点击消息时执行的业务操作(如打开指定页面等)。
+

+
+ +
+
+
+
+

Android

+

+在系统消息中心显示推送通知,点击通知启动(激活)应用到前台运行,触发“click”事件。 +

+

+应用在线(个推推送通道可用):推送通知和透传消息都使用个推的推送通道下发推送消息。 +

+

+应用离线(个推推送通道不可用):推送通知,使用个推离线推送通道,离线消息会存储在消息离线库,离线时间内APP在线后下发推送消息。透传消息,如果符合厂商推送的厂商手机(配置了手机厂商推送参数并且在对应厂商的手机上),则使用厂商推送通道下发推送消息;否则使用个推的离线推送通道,离线消息会存储在消息离线库,离线时间内APP在线后下发推送消息。 +

+

iOS

+

+Todo: 开发中... +

+
+ + diff --git a/push/UniPush/payload/Payload.php b/push/UniPush/payload/Payload.php new file mode 100644 index 0000000..7cc34f0 --- /dev/null +++ b/push/UniPush/payload/Payload.php @@ -0,0 +1,7 @@ +voIPPayload; + if($payload == null || empty($payload)){ + throw new RuntimeException("payload cannot be empty"); + } + $params = array(); + if($payload != null){ + $params["payload"] = $payload; + } + $params["isVoIP"] = 1; + return json_encode($params); + } + + public function setVoIPPayload($voIPPayload){ + $this->voIPPayload = $voIPPayload; + } + +} \ No newline at end of file diff --git a/push/UniPush/protobuf/encoding/pb_base128.php b/push/UniPush/protobuf/encoding/pb_base128.php new file mode 100644 index 0000000..69d6ba6 --- /dev/null +++ b/push/UniPush/protobuf/encoding/pb_base128.php @@ -0,0 +1,113 @@ +modus = $modus; + } + + + /** + * @param $number - number as decimal + * Returns the base128 value of an dec value + */ + public function set_value($number) + { + $string = decbin($number); + if (strlen($string) < 8) + { + $hexstring = dechex(bindec($string)); + if (strlen($hexstring) % 2 == 1) + $hexstring = '0' . $hexstring; + if ($this->modus == 1) + { + return $this->hex_to_str($hexstring); + } + return $hexstring; + } + + // split it and insert the mb byte + $string_array = array(); + $pre = '1'; + while (strlen($string) > 0) + { + if (strlen($string) < 8) + { + $string = substr('00000000', 0, 7 - strlen($string) % 7) . $string; + $pre = '0'; + } + $string_array[] = $pre . substr($string, strlen($string) - 7, 7); + $string = substr($string, 0, strlen($string) - 7); + $pre = '1'; + if ($string == '0000000') + break; + } + + $hexstring = ''; + foreach ($string_array as $string) + { + $hexstring .= sprintf('%02X', bindec($string)); + } + + // now format to hexstring in the right format + if ($this->modus == 1) + { + return $this->hex_to_str($hexstring); + } + + return $hexstring; + } + + + /** + * Returns the dec value of an base128 + * @param string bstring + */ + public function get_value($string) + { + // now just drop the msb and reorder it + parse it in own string + $valuestring = ''; + $string_length = strlen($string); + + $i = 1; + + while ($string_length > $i) + { + // unset msb string and reorder it + $valuestring = substr($string, $i, 7) . $valuestring; + $i += 8; + } + + // now interprete it + return bindec($valuestring); + } + + /** + * Converts hex 2 ascii + * @param String $hex - the hex string + */ + public function hex_to_str($hex) + { + $str = ''; + + for($i = 0; $i < strlen($hex); $i += 2) + { + $str .= chr(hexdec(substr($hex, $i, 2))); + } + return $str; + } + +} + +?> diff --git a/push/UniPush/protobuf/pb_message.php b/push/UniPush/protobuf/pb_message.php new file mode 100644 index 0000000..f47f265 --- /dev/null +++ b/push/UniPush/protobuf/pb_message.php @@ -0,0 +1,402 @@ +reader = $reader; + $this->value = $this; + $this->base128 = new base128varint(PBMessage::MODUS); + } + + /** + * Get the wired_type and field_type + * @param $number as decimal + * @return array wired_type, field_type + */ + public function get_types($number) + { + $binstring = decbin($number); + $types = array(); + $low = substr($binstring, strlen($binstring) - 3, strlen($binstring)); + $high = substr($binstring,0, strlen($binstring) - 3) . '0000'; + $types['wired'] = bindec($low); + $types['field'] = bindec($binstring) >> 3; + return $types; + } + + + /** + * Encodes a Message + * @return string the encoded message + */ + public function SerializeToString($rec=-1) + { + $string = ''; + // wired and type + if ($rec > -1) + { + $string .= $this->base128->set_value($rec << 3 | $this->wired_type); + } + + $stringinner = ''; + + foreach ($this->fields as $index => $field) + { + if (is_array($this->values[$index]) && count($this->values[$index]) > 0) + { + // make serialization for every array + foreach ($this->values[$index] as $array) + { + $newstring = ''; + $newstring .= $array->SerializeToString($index); + + $stringinner .= $newstring; + } + } + else if ($this->values[$index] != null) + { + // wired and type + $newstring = ''; + $newstring .= $this->values[$index]->SerializeToString($index); + + $stringinner .= $newstring; + } + } + + $this->_serialize_chunk($stringinner); + + if ($this->wired_type == PBMessage::WIRED_LENGTH_DELIMITED && $rec > -1) + { + $stringinner = $this->base128->set_value(strlen($stringinner) / PBMessage::MODUS) . $stringinner; + } + + return $string . $stringinner; + } + + /** + * Serializes the chunk + * @param String $stringinner - String where to append the chunk + */ + public function _serialize_chunk(&$stringinner) + { + $stringinner .= $this->chunk; + } + + /** + * Decodes a Message and Built its things + * + * @param message as stream of hex example '1a 03 08 96 01' + */ + public function ParseFromString($message) + { + $this->reader = new PBInputStringReader($message); + $this->_ParseFromArray(); + } + + /** + * Internal function + */ + public function ParseFromArray() + { + $this->chunk = ''; + // read the length byte + $length = $this->reader->next(); + // just take the splice from this array + $this->_ParseFromArray($length); + } + + /** + * Internal function + */ + private function _ParseFromArray($length=99999999) + { + $_begin = $this->reader->get_pointer(); + while ($this->reader->get_pointer() - $_begin < $length) + { + $next = $this->reader->next(); + if ($next === false) + break; + + // now get the message type + $messtypes = $this->get_types($next); + + // now make method test + if (!isset($this->fields[$messtypes['field']])) + { + // field is unknown so just ignore it + // throw new Exception('Field ' . $messtypes['field'] . ' not present '); + if ($messtypes['wired'] == PBMessage::WIRED_LENGTH_DELIMITED) + { + $consume = new PBString($this->reader); + } + else if ($messtypes['wired'] == PBMessage::WIRED_VARINT) + { + $consume = new PBInt($this->reader); + } + else + { + throw new Exception('I dont understand this wired code:' . $messtypes['wired']); + } + + // perhaps send a warning out + // @TODO SEND CHUNK WARNING + $_oldpointer = $this->reader->get_pointer(); + $consume->ParseFromArray(); + // now add array from _oldpointer to pointer to the chunk array + $this->chunk .= $this->reader->get_message_from($_oldpointer); + continue; + } + + // now array or not + if (is_array($this->values[$messtypes['field']])) + { + $this->values[$messtypes['field']][] = new $this->fields[$messtypes['field']]($this->reader); + $index = count($this->values[$messtypes['field']]) - 1; + if ($messtypes['wired'] != $this->values[$messtypes['field']][$index]->wired_type) + { + throw new Exception('Expected type:' . $messtypes['wired'] . ' but had ' . $this->fields[$messtypes['field']]->wired_type); + } + $this->values[$messtypes['field']][$index]->ParseFromArray(); + } + else + { + $this->values[$messtypes['field']] = new $this->fields[$messtypes['field']]($this->reader); + if ($messtypes['wired'] != $this->values[$messtypes['field']]->wired_type) + { + throw new Exception('Expected type:' . $messtypes['wired'] . ' but had ' . $this->fields[$messtypes['field']]->wired_type); + } + $this->values[$messtypes['field']]->ParseFromArray(); + } + } + } + + /** + * Add an array value + * @param int - index of the field + */ + protected function _add_arr_value($index) + { + return $this->values[$index][] = new $this->fields[$index](); + } + + /** + * Set an array value - @TODO failure check + * @param int - index of the field + * @param int - index of the array + * @param object - the value + */ + protected function _set_arr_value($index, $index_arr, $value) + { + $this->values[$index][$index_arr] = $value; + } + + /** + * Remove the last array value + * @param int - index of the field + */ + protected function _remove_last_arr_value($index) + { + array_pop($this->values[$index]); + } + + /** + * Set an value + * @param int - index of the field + * @param Mixed value + */ + protected function _set_value($index, $value) + { + if (gettype($value) == 'object') + { + $this->values[$index] = $value; + } + else + { + $this->values[$index] = new $this->fields[$index](); + $this->values[$index]->value = $value; + } + } + + /** + * Get a value + * @param id of the field + */ + protected function _get_value($index) + { + if ($this->values[$index] == null) + return null; + return $this->values[$index]->value; + } + + /** + * Get array value + * @param id of the field + * @param value + */ + protected function _get_arr_value($index, $value) + { + return $this->values[$index][$value]; + } + + /** + * Get array size + * @param id of the field + */ + protected function _get_arr_size($index) + { + return count($this->values[$index]); + } + + /** + * Helper method for send string + */ + protected function _save_string($ch, $string) + { + $this->_d_string .= $string; + $content_length = strlen($this->_d_string); + return strlen($string); + } + + /** + * Sends the message via post request ['message'] to the url + * @param the url + * @param the PBMessage class where the request should be encoded + * + * @return String - the return string from the request to the url + */ + public function Send($url, &$class = null) + { + $ch = curl_init(); + $this->_d_string = ''; + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($this, '_save_string')); + curl_setopt($ch, CURLOPT_POSTFIELDS, 'message=' . urlencode($this->SerializeToString())); + $result = curl_exec($ch); + + if ($class != null) + $class->parseFromString($this->_d_string); + return $this->_d_string; + } + + /** + * Fix Memory Leaks with Objects in PHP 5 + * http://paul-m-jones.com/?p=262 + * + * thanks to cheton + * http://code.google.com/p/pb4php/issues/detail?id=3&can=1 + */ + public function _destruct() + { + if (isset($this->reader)) + { + unset($this->reader); + } + if (isset($this->value)) + { + unset($this->value); + } + // base128 + if (isset($this->base128)) + { + unset($this->base128); + } + // fields + if (isset($this->fields)) + { + foreach ($this->fields as $name => $value) + { + unset($this->$name); + } + unset($this->fields); + } + // values + if (isset($this->values)) + { + foreach ($this->values as $name => $value) + { + if (is_array($value)) + { + foreach ($value as $name2 => $value2) + { + if (is_object($value2) AND method_exists($value2, '__destruct')) + { + $value2->__destruct(); + } + unset($value2); + } + if (isset($name2)) + unset($value->$name2); + } + else + { + if (is_object($value) AND method_exists($value, '__destruct')) + { + $value->__destruct(); + } + unset($value); + } + unset($this->values->$name); + } + unset($this->values); + } + } + +} +?> diff --git a/push/UniPush/protobuf/reader/pb_input_reader.php b/push/UniPush/protobuf/reader/pb_input_reader.php new file mode 100644 index 0000000..bf9a3c7 --- /dev/null +++ b/push/UniPush/protobuf/reader/pb_input_reader.php @@ -0,0 +1,50 @@ +base128 = new base128varint(1); + } + + /** + * Gets the acutal position of the point + * @return int the pointer + */ + public function get_pointer() + { + return $this->pointer; + } + + /** + * Add add to the pointer + * @param int $add - int to add to the pointer + */ + public function add_pointer($add) + { + $this->pointer += $add; + } + + /** + * Get the message from from to actual pointer + * @param from + */ + public function get_message_from($from) + { + return substr($this->string, $from, $this->pointer - $from); + } + + /** + * Getting the next varint as decimal number + * @return varint + */ + public abstract function next(); +} +?> diff --git a/push/UniPush/protobuf/reader/pb_input_string_reader.php b/push/UniPush/protobuf/reader/pb_input_string_reader.php new file mode 100644 index 0000000..f1ca395 --- /dev/null +++ b/push/UniPush/protobuf/reader/pb_input_string_reader.php @@ -0,0 +1,53 @@ +string = $string; + $this->length = strlen($string); + } + + /** + * get the next + * @param boolean $is_string - if set to true only one byte is read + */ + public function next($is_string = false) + { + $package = ''; + while (true) + { + if ($this->pointer >= $this->length) + { + return false; + } + + $string = ''; + $string = $this->string[$this->pointer]; + $this->pointer++; + + if ($is_string == true) + return ord($string); + + $value = decbin(ord($string)); + + if ($value >= 10000000 && $is_string == false) + { + // now fill to eight with 00 + $package .= $value; + } + else + { + // now fill to length of eight with 0 + $value = substr('00000000', 0, 8 - strlen($value) % 8) . $value; + return $this->base128->get_value($package . $value); + } + } + } +} +?> diff --git a/push/UniPush/protobuf/type/pb_bool.php b/push/UniPush/protobuf/type/pb_bool.php new file mode 100644 index 0000000..9a67ede --- /dev/null +++ b/push/UniPush/protobuf/type/pb_bool.php @@ -0,0 +1,21 @@ +value = $this->reader->next(); + $this->value = ($this->value != 0) ? 1 : 0; + } + +} +?> diff --git a/push/UniPush/protobuf/type/pb_bytes.php b/push/UniPush/protobuf/type/pb_bytes.php new file mode 100644 index 0000000..2430d36 --- /dev/null +++ b/push/UniPush/protobuf/type/pb_bytes.php @@ -0,0 +1,44 @@ +value = ''; + // first byte is length + $length = $this->reader->next(); + + // just extract the string + $pointer = $this->reader->get_pointer(); + $this->reader->add_pointer($length); + $this->value = $this->reader->get_message_from($pointer); + } + + /** + * Serializes type + */ + public function SerializeToString($rec = -1) + { + $string = ''; + + if ($rec > -1) + { + $string .= $this->base128->set_value($rec << 3 | $this->wired_type); + } + + $string .= $this->base128->set_value(strlen($this->value)); + $string .= $this->value; + + return $string; + } +} +?> diff --git a/push/UniPush/protobuf/type/pb_enum.php b/push/UniPush/protobuf/type/pb_enum.php new file mode 100644 index 0000000..28c10e3 --- /dev/null +++ b/push/UniPush/protobuf/type/pb_enum.php @@ -0,0 +1,37 @@ +value = $this->reader->next(); + } + + /** + * Serializes type + */ + public function SerializeToString($rec=-1) + { + $string = ''; + + if ($rec > -1) + { + $string .= $this->base128->set_value($rec << 3 | $this->wired_type); + } + + $value = $this->base128->set_value($this->value); + $string .= $value; + + return $string; + } +} +?> diff --git a/push/UniPush/protobuf/type/pb_int.php b/push/UniPush/protobuf/type/pb_int.php new file mode 100644 index 0000000..802e708 --- /dev/null +++ b/push/UniPush/protobuf/type/pb_int.php @@ -0,0 +1,38 @@ +value = $this->reader->next(); + } + + /** + * Serializes type + */ + public function SerializeToString($rec=-1) + { + // first byte is length byte + $string = ''; + + if ($rec > -1) + { + $string .= $this->base128->set_value($rec << 3 | $this->wired_type); + } + + $value = $this->base128->set_value($this->value); + $string .= $value; + + return $string; + } +} +?> diff --git a/push/UniPush/protobuf/type/pb_scalar.php b/push/UniPush/protobuf/type/pb_scalar.php new file mode 100644 index 0000000..e1db06a --- /dev/null +++ b/push/UniPush/protobuf/type/pb_scalar.php @@ -0,0 +1,23 @@ +value = $value; + } + + /** + * Get the scalar value + */ + public function get_value() + { + return $this->value; + } +} +?> diff --git a/push/UniPush/protobuf/type/pb_signed_int.php b/push/UniPush/protobuf/type/pb_signed_int.php new file mode 100644 index 0000000..66e7af1 --- /dev/null +++ b/push/UniPush/protobuf/type/pb_signed_int.php @@ -0,0 +1,48 @@ +value; + $this->value = round($this->value / 2); + if ($saved % 2 == 1) + { + $this->value = -($this->value); + } + } + + /** + * Serializes type + */ + public function SerializeToString($rec=-1) + { + // now convert signed int to int + $save = $this->value; + if ($this->value < 0) + { + $this->value = abs($this->value)*2-1; + } + else + { + $this->value = $this->value*2; + } + $string = parent::SerializeToString($rec); + // restore value + $this->value = $save; + + return $string; + } +} +?> diff --git a/push/UniPush/protobuf/type/pb_string.php b/push/UniPush/protobuf/type/pb_string.php new file mode 100644 index 0000000..de49ed9 --- /dev/null +++ b/push/UniPush/protobuf/type/pb_string.php @@ -0,0 +1,44 @@ +value = ''; + // first byte is length + $length = $this->reader->next(); + + // just extract the string + $pointer = $this->reader->get_pointer(); + $this->reader->add_pointer($length); + $this->value = $this->reader->get_message_from($pointer); + } + + /** + * Serializes type + */ + public function SerializeToString($rec = -1) + { + $string = ''; + + if ($rec > -1) + { + $string .= $this->base128->set_value($rec << 3 | $this->wired_type); + } + + $string .= $this->base128->set_value(strlen($this->value)); + $string .= $this->value; + + return $string; + } +} +?> diff --git a/push/UniPush/push.php b/push/UniPush/push.php new file mode 100644 index 0000000..fd37ac4 --- /dev/null +++ b/push/UniPush/push.php @@ -0,0 +1,77 @@ +set_appId(APPID);//应用appid + $template->set_appkey(APPKEY);//应用appkey + $template->set_transmissionType(2);//透传消息类型:1为激活客户端启动 + $template->set_transmissionContent($p);//透传内容 + //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 + + $notify = new IGtNotify(); + $notify->set_title($t); + $notify->set_content($c); + $notify->set_intent($i); + $notify->set_type(NotifyInfo_type::_intent); + + $template->set3rdNotifyInfo($notify); + + return $template; +} + +$cid = ''; +$title = ''; +$content = ''; +$payload = ''; +$package = PACKAGENAME;//包名 + +switch (@$_SERVER['REQUEST_METHOD']) { + case 'POST': + $cid = @$_POST['cid']; + $title = @$_POST['title']; + $content = @$_POST['content']; + $payload = @$_POST['payload']; + break; + case 'GET': + $cid = @$_GET['cid']; + $title = @$_GET['title']; + $content = @$_GET['content']; + $payload = @$_GET['payload']; + break; + default: + break; +} + +if(empty($cid)){ + error('无效的终端标识(cid)'); + return; +}else if(empty($title)){ + error('无效的通知标题(title)'); + return; +}else if(empty($content)){ + error('无效的通知内容(content)'); + return; +} + + +// 生成指定格式的intent支持厂商推送通道 +$intent = "intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component={$package}/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title={$title};S.content={$content};S.payload={$payload};end"; + + +pushMessageToSingle(createPushMessage($payload,$intent,$title,$content), $cid); +