static function pushBaidu($notifyMsg) { if ($notifyMsg->type === NotificationsManager::DEVICE_ISO) { $channel = NotificationsManager::initBaiduCertIOS($notifyMsg); } else { $channel = new Channel($notifyMsg->appid, $notifyMsg->restkey); } $message_key = md5(date('Y-m-d-H-M-S', time())); $optional[Channel::MESSAGE_TYPE] = 1; // if(isset($notifyMsg->channels) && is_array($notifyMsg->channels) && count($notifyMsg->channels)>0){ // $push_type = 2; // }else { // $push_type = 3; //推送广播消息 // } $push_type = 3; $message = array(); if ($notifyMsg->type === NotificationsManager::DEVICE_ISO) { $optional[Channel::DEVICE_TYPE] = 4; $apps = array(); if (isset($notifyMsg->title) && !is_null($notifyMsg->title)) { $message['title'] = $notifyMsg->title; } $optional[Channel::DEVICE_TYPE] = 4; if (isset($notifyMsg->prod_id) && !is_null($notifyMsg->prod_id)) { $message['prod_id'] = $notifyMsg->prod_id; } if (isset($notifyMsg->prod_type) && !is_null($notifyMsg->prod_type)) { $message['prod_type'] = $notifyMsg->prod_type; } if (isset($notifyMsg->push_type) && !is_null($notifyMsg->push_type)) { $message['push_type'] = $notifyMsg->push_type; } if (isset($notifyMsg->alert) && !is_null($notifyMsg->alert)) { $apps['alert'] = $notifyMsg->alert; } $apps['Sound'] = ''; $apps['Badge'] = 0; $message['aps'] = $apps; } else { if ($notifyMsg->type === NotificationsManager::DEVICE_ANDROID) { $custom_content = array(); if (isset($notifyMsg->title) && !is_null($notifyMsg->title)) { $message['title'] = $notifyMsg->title; } $optional[Channel::DEVICE_TYPE] = 3; if (isset($notifyMsg->prod_id) && !is_null($notifyMsg->prod_id)) { $custom_content['prod_id'] = $notifyMsg->prod_id; } if (isset($notifyMsg->prod_type) && !is_null($notifyMsg->prod_type)) { $custom_content['prod_type'] = $notifyMsg->prod_type; } if (isset($notifyMsg->push_type) && !is_null($notifyMsg->push_type)) { $custom_content['push_type'] = $notifyMsg->push_type; } if (isset($notifyMsg->alert) && !is_null($notifyMsg->alert)) { $message['description'] = $notifyMsg->alert; } $message['custom_content'] = $custom_content; } } // var_dump($message); var_dump($optional); $ret = $channel->pushMessage($push_type, $message, $message_key, $optional); if (false === $ret) { return array('code' => '201', 'response' => $channel->errmsg()); } else { return array('code' => '200', 'response' => $ret); } }