iosKey = '8a5efd65cda14fafa6e64ad3'; $this->iosSecret = 'daebe19b547c43128796a078'; // 安卓 $this->azKey = 'b5f679f4357018605ea6fd2e'; $this->azSecret = 'c4fb573758f8d7058d697c54'; } public function sendMsg($register_id,$message,$route = '',$type = 1){ $res = true; try { $this->client = new Client($this->iosKey, $this->iosSecret); $this->push = $this->client->push(); $this->push->setPlatform(['android', 'ios']); $this->push->addRegistrationId($register_id); $this->push->iosNotification($message, ['extras' => ['route' => $route, 'type' => $type]]); $this->push->send(); unset($this->client, $this->push); } catch (\Exception $e) { Log::error($e->getMessage()); $res = false; } try { $this->client = new Client($this->azKey, $this->azSecret); $this->push = $this->client->push(); $this->push->setPlatform(['android', 'ios']); $this->push->addRegistrationId($register_id); $this->push->androidNotification($message, ['extras' => ['route' => $route, 'type' => $type]]); $this->push->send(); unset($this->client, $this->push); $res = true; } catch (\Exception $e) { Log::error($e->getMessage()); $res = false; } return $res; } }