最近公司項目須要用到APP推送消息 ,找到比較詳細的相關的資料跟你們分享`http://www.cnblogs.com/jiqing...html
下面是我本身的推送內容,已經成功發送,首先在獲取極光推送的key和secret,並下載相關sdk
1.推送的通知消息服務器
protected static $client; public function __construct() { static::$client = new \JPush\Client(t($config['key']), t($config['secret'])); } /** *給指定用戶推送通知消息 *$uis設備別名,由設備設置傳給服務器端 *$device設備類型 *$result通知內容 */ public function pushMsgtoUser($uis, $device, $result) { $options = array( 'audience' => $uis ); $result = static::$client->push()->setPlatform($device)->addAllAudience() ->setNotificationAlert($result)->options($options)->send(); return $result; } /** *給全部用戶推送通知消息 **$result通知內容 */ public function pushAllMsg($result) { $result = static::$client->push()->setPlatform('all')->addAllAudience()->setNotificationAlert($result)->send(); return $result; } /** *給全部用戶推送自定義消息 **$result通知內容 */ public function pushMsg($result) { $options = array( 'time_to_live' => 0, ); $result = static::$client->push()->setPlatform('all')->addAllAudience() ->message($result)->options($options)->send(); return $result; } /** *給全部用戶(指定用戶 需設定addRegistrationId而且去掉addAllAudience)推送自定義消息,彈出通知內容,點擊消息進入這定頁面 **$result通知內容 */ public function pushMsgAddUrl($push_data, $push_token=null) { $tmp = static::$client->push() ->setPlatform("all") ->addAllAudience() // ->addRegistrationId($push_token) ->addAndroidNotification($push_data['content'], $push_data['title'], 1, array("controller" => $push_data['controller'], "method" => $push_data['method'], 'param' => $push_data['param'])) ->addIosNotification($push_data['content'], '$push_data['title']', '+1', true, 'iOS category', array("controller" => $push_data['controller'], "method" => $push_data['method'], 'param' => $push_data['param'])) ->send(); return $tmp; }