APP的訊息推送(極光推送)

來源:互聯網
上載者:User

標籤:

APP的訊息推送,使用的第三方平台是極光推送

 

簡單案例(以Thinkphp為例):

1、下載下載PHPSDK

2、把PHPSDK目錄下的jpush-api-php-client-3.5.1\src\JPush,Jpush下全部檔案複製到項目中:ThinkPHP\Library\Org\JPush

3、thinkphp中Org下面的檔案會自動載入

$client = new \Org\Push\Client($app_key, $master_secret);            $push = $client->push();            $push->setPlatform(array(‘ios‘, ‘android‘));            //根據裝置id,向每一個使用者推送。$registrationid_arr為數組,一次推送最多 1000 個。            $push->addRegistrationId($registrationid_arr);            //false: ios推送的為開發環境            $push->options(array(                ‘apns_production‘=>false,                //表示離線訊息保留時間長度(秒),預設儲存1天//                ‘time_to_live‘=>86400,            ));            $push->setNotificationAlert(‘您有新的匹配訂單,請儘快報價!‘);            $push->send();

 4、根據registrationid(註冊id、或者叫裝置id)推送,需要把裝置id儲存到資料庫。即需要寫一個介面,到使用者登陸成功時,請求這個介面,把APP當前登陸(最後  登陸)使用者的裝置id和使用者id,綁定儲存到使用者表。

  當想給這個使用者推送訊息時,根據使用者id找到使用者對應的裝置id,進行推送即可。
 

 

 

 

參考:

極光文檔:

  (Push API v3)http://community.apicloud.com/bbs/forum.php?mod=viewthread&tid=2420&page=1#pid21227

  https://github.com/jpush/jpush-api-php-client/blob/master/doc/api.md#sms-message

極光控制台:https://www.jiguang.cn/app/list

其他:

    http://www.dodobook.net/php/780

  http://www.111cn.net/phper/thinkPhp/112810.htm

  http://www.bubuko.com/infodetail-589128.html

   

 

APP的訊息推送(極光推送)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.