极光推送

Posted *紫色薰衣草*

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了极光推送相关的知识,希望对你有一定的参考价值。

require ‘./data/jpush/autoload.php‘;
             $master_secret = ‘5d561fe4042e4fe3ccc06a4e‘;
             $app_key=‘6089a3bc7cb29c8b72b4e21d‘;
             $client = new \JPush\Client($app_key, $master_secret);
             $message = "请支付货款";

            try {
                 $tmp = $client->push()
                                ->setPlatform(‘all‘)
                                ->addAlias($res["uid"])
                                ->setNotificationAlert($message)
                                ->addandroidNotification($message, $message, 1,array("ty"=>10,"type"=>$res["type"],"uid"=>$res["uid"],"order_id"=>$res["order_id"]))
                                ->addiosNotification($message, ‘default‘, ‘+1‘, true, ‘iOS category‘,array("ty"=>10,"type"=>$res["type"],"uid"=>$res["uid"],"order_id"=>$res["order_id"]))
                                ->setOptions($sendno = 12, $time_to_live = null, $override_msg_id = null, $apns_production = false, $big_push_duration = null)
                                ->send();
                
                $data["tongzhi_time"] = time();
                $data["ctime"] = time();
                $data["is_tongzhi"] = 1;
                $data["static"] = 6;
                M("order")->where("order_id=‘$order‘")->save($data);
                $dat["type"] = 1;
                $dat["u_type"] = 1;
                $dat["m_type"] = 3;
                $dat["uid"] = $res["uid"];
                $dat["title"] = $message;
                $dat["d_id"] = $res["order_id"];
                $dat["ctime"] = time();
                M("message")->add($dat);
            } catch (\JPush\Exceptions\APIConnectionException $e) {
                // try something here
                print $e;
            } catch (\JPush\Exceptions\APIRequestException $e) {
                // try something here
                print $e;
            }
            json(200);

 

//安卓 和demo中一样

->androidNotification($message, array(
                            ‘title‘ => $message,
                            ‘sound‘ => "./public/jpush/notify.mp3",
                            ‘o_id‘  => $o_id,
                            // ‘build_id‘ => 2,
                            // ‘extras‘ => array(
                            //     ‘key‘ => ‘value‘,
                            //     ‘jiguang‘
                            // ),
                        ))

以上是关于极光推送的主要内容,如果未能解决你的问题,请参考以下文章

cordova 极光推送设置别名技巧

极光推送——别名设置

iOS 极光推送诶配置成功却收不到推送消息的处理

iOS极光推送别名限制问题

极光推送服务器端向ios端推送消息需要设置哪些参数

极光推送的自定义消息推送之后ios怎么使用