CI框架引入极光推送

2017-06-14  本文已影响0人  程序猿某人_

目录如下
在libraries中引入极光api

1497436800(1).png

在libraties中创建jpush.php文件,代码如下

  public function send($_msg_body = 'Hello, JPush', $_alias = 'all', $_platform = 'all'){
            $client = new \JPush\Client($this->_key, $this->_secret);        
            $pusher = $client->push();
            $pusher->setPlatform($_platform );
            if(strtolower($_alias) == 'all'){
                $pusher->addAllAudience();
            }else{
                $pusher->addAlias($_alias);        
            }
            $pusher->setNotificationAlert($_msg_body);
            
            try {
                $_rs = $pusher->send();
            } catch (\JPush\Exceptions\JPushException $e) {
                $_rs = $e;
            }
            return $_rs;
        }
   

控制器直接调用该方法即可,传入相关的账号信息。。

上一篇 下一篇

猜你喜欢

热点阅读