博主信息
博文 2
粉丝 0
评论 0
访问量 2511
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
腾讯移动推送 TPNS
De l'eau.
原创
1325人浏览过

腾讯 移动推送 TPNS

Github地址 去 fork or star 有问题还能找到

官方接口文档

安装

  1. composer require code-lives/app-push-tpns 1.1.0

配置参数说明

需要配置的参数

参数名字 类型 说明
appid string 申请的appid
secretKey string 申请的appsecretkey
environment string 用户指定推送环境,仅限 iOS 平台推送使用 默认 product;推送生产环境;dev推送开发环境

Config Demo

本地config的配置

  1. $config = [
  2. 'appid' => '',
  3. 'secretKey' => '',
  4. 'environment'=>''
  5. ];

全量推送

给所有安装app的用户发送消息。

  1. $content=[
  2. 'title'=>'标题',
  3. 'content'=>'内容'
  4. ];
  5. $app_push = new AppPush($config);
  6. $app_push->send_all($content,'notify');

单账号推送或多账号推送

一对一给用户发送消息 或 多个账号发送消息

参数名字 类型 说明
content string 内容
account array 根据数量判断 单账号或多账号推送
message_type string 默认:notify(可不传);notify:通知;message:透传消息/静默消息
  1. $account=['one'];//单账号推送
  2. $account=['one','two'];//多个账号推送
  3. $app_push->send_account($content, $account,$message_type);

单设备推送或多设备推送

单或多设备推送 传递数量判断

参数名字 类型 说明
content string 内容
token array 根据数量判断 单设备或多设备
message_type string 默认:notify(可不传);notify:通知;message:透传消息/静默消息
  1. $token=['one'];//单设备推送
  2. $token=['one','two'];//多个设备推送
  3. $app_push->send_token($content, $token,$message_type);

标签推送

tag 字段根据开发文档 tag_items 字段 自定义

参数名字 类型 说明
content string 内容
tag array 根据开发文档 tag_items 字段 封装
message_type string 默认:notify(可不传); notify:通知;message:透传消息/静默消息
  1. $app_push->send_tag($content, $tag,$message_type);

标签绑定与解绑

参数名字 类型 说明
operator_type int 类型看官方文档1-10
array array operator_type(1-8) [‘token_list’=>] operator_type(9-10) [‘tag_token_list’=>]
tag_array array operator_type = 1,2,3,4,6,7,8时 [‘tag_list’=>] operator_type(9-10)可不传递
  1. //1-8
  2. $operator_type = 1;
  3. $array = ['token_list' => []];
  4. $tag_array = ['tag_list' => []];
  5. $app_push->set_tag($operator_type, $array = [], $tag_array = []);
  6. //9-10
  7. $operator_type = 9;
  8. $array = ['tag_token_list' => []];
  9. $app_push->set_tag($operator_type, $array = []);

删除标签下所有设备

参数名字 类型 说明
tag_list array 待删除标签列表:”tag_list”: [“test_tag_3_Ik0N0”, “test_tag_2_Ik0N0”]
  1. $app_push->delete_tag(['tag_list'=>[]]);

账号绑定与解绑

array 根据开发文档->账号相关接口->账号绑定与解绑

参数名字 类型 说明
operator_type int 类型看官方文档
array array 查看文档
  1. $operator_type = 1;
  2. $array = ['account_list' => []];
  3. $array = ['token_list' => []];
  4. $array = ['token_accounts' => []];
  5. $app_push->account_save($operator_type, $array);

账号查询

array 根据开发文档->账号相关接口->账号设备绑定查询

参数名字 类型 说明
operator_type int 类型看官方文档
array array 查看文档
  1. $operator_type = 1;
  2. $array = ['account_list' => []];
  3. $array = ['token_list' => []];
  4. $app_push->account_query($operator_type, $array);
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学