zoukankan      html  css  js  c++  java
  • 极光推送

    2016年10月20日 16:24:01 星期四

    发给指定用户的流程:

    1. 用户每次登录, 都会生成一个新的 registration ID 存入数据库, 与uid对应

    2. 发送时取出该registration ID, 当作参数传递给接口发送

     1 require 'path_to/JPush/autoload.php';
     2 
     3 use JPushClient as JPush;
     4 
     5 class JCPush
     6 {
     7     public $client = FALSE;
     8     public function __construct()
     9     {
    10         $appkey = C('JPush_Appkey');
    11         $master_secret = C('JPush_Master_Secret');
    12         $this->client = new JPush($appkey, $master_secret);
    13     }
    14 
    15     public function pushMsg($uid, $msg, $platform='all')
    16     {
    17         $jpushId = M('table')->where(['uid' => $uid])->getField('registration_id'); //可以写入缓存, 不要循环查库
    18         $response = $this->client->push()
    19             ->setPlatform($platform)
    20             ->addRegistrationId($jpushId)
    21             ->setNotificationAlert($msg)
    22             ->send();
    23         return $response;
    24 
    25 //        Array
    26 //        (
    27 //            [body] => Array
    28 //                          (
    29 //                              [sendno] => 0
    30 //                            [msg_id] => 3318558882
    31 //                        )
    32 //
    33 //            [http_code] => 200
    34 //            [headers] => Array
    35 //                     (
    36 //                         [rateLimitLimit] => 600
    37 //                        [rateLimitRemaining] => 599
    38 //                        [rateLimitReset] => 60
    39 //                    )
    40 //
    41 //        )
    42     }
    43 }
  • 相关阅读:
    优酷kux转mp4
    C++实现将一个文件夹内容拷贝至另一个文件夹
    获取NX一组属性
    获取NX特征名称(无时间戳)
    利用glog打印日志
    C++获取运行程序当前目录
    获取NX装配结构信息
    解析形如(k,v)(k,v)(k,v)字符串
    多NX如何共存
    C++ (C#)实现获取NX PART预览图
  • 原文地址:https://www.cnblogs.com/iLoveMyD/p/5981385.html
Copyright © 2011-2022 走看看