项目中用到了给客户端的推送功能,选用了极光推送,下面演示一下在thinkphp中集成极光推送

1.下载极光推送的php类,可以从笔者的git下载

地址:https://git.oschina.net/zhangchao123/jiguangtuisongphplei.git

2.thinkphp集成

解压后,直接把jpush文件夹放在Thinkphp/Libray/Vender目录

/*
   * 极光推送
   * $pushId:极光ID,字符串或者array()
   * $content:推送内容
   * $remark:备注
   * $type:推送类型参数array()
  */

function pushMessage($pushId,$content,$remark,$type){
      vendor('JPush.JPush');
      $jPush = C('jPush');
      $app_key = $jPush['app_key'];
      $master_secret = $jPush['master_secret'];
      $client = new \JPush($app_key, $master_secret);
      $result = $client->push()
               ->setPlatform('all')
               ->addRegistrationId($pushId)
               ->addAndroidNotification($content,"'".$remark."'", 1,$type)
               ->addIosNotification($content, 'iOS sound', '+1', true, 'iOS category',$type)
               ->send();
     return $result;
  }

最新文章

  1. C#设计模式系列:开闭原则(Open Close Principle)
  2. 使用Chrome工具来分析页面的绘制状态
  3. Mysql的ssl主从复制+半同步主从复制
  4. [翻译]The Neophyte's Guide to Scala Part 12: Type Classes
  5. jquery在线教程
  6. Python3 基础
  7. 【转】ListView与RadioButton组合——自定义单选列表
  8. c/c++ 直接使用动态库 dlopen
  9. vue-cli创建自己的项目
  10. PHPStudy+PHPStorm下配置隐藏项目入口文件
  11. 【一天一道LeetCode】#22. Generate Parentheses
  12. [Swift]LeetCode704. 二分查找 | Binary Search
  13. Asp.Net Core 下 Newtonsoft.Json 转换字符串 null 替换成string.Empty
  14. C#-类(九)
  15. Feature Extractor[inception v2 v3]
  16. echarts 导出图片,并将图片导出pdf格式
  17. MVC 中Delete 方法报错问题解决方案
  18. SpringBoot笔记--Jackson
  19. MacBook快速入门
  20. m序列c语言实现

热门文章

  1. Node中的cookie的使用
  2. HTML5新增的表单验证功能
  3. 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数 例如给定nums = [2,7,11,15],target = 9
  4. java虚拟机-GC-新生代的GC、老年代的GC
  5. HDU 4461:The Power of Xiangqi(水题)
  6. 利用os模块生成 文件夹和文件
  7. 数据结构丨N叉树
  8. dubbo框架设计学习
  9. 简单的量子算法(二):Simon's Algorithm
  10. [leetcode] 7. Reverse Integer (easy)