Documentation ¶
Index ¶
- Constants
- Variables
- func HttpRequest(method, url, token string, bodyByte []byte) ([]byte, error)
- func RequestAPI(method, url, token string, bodyByte []byte) (*models.Response, error)
- type ClientType
- type MessageType
- func (m MessageType) GetHonorImportance() (importance string)
- func (m MessageType) GetHuaweiCategory() string
- func (m MessageType) GetHuaweiChannelId() string
- func (m MessageType) GetHuaweiImportance() string
- func (m MessageType) GetHuaweiInfo() (channelId, category, importance string)
- func (m MessageType) GetOPPOChannelId() string
- func (m MessageType) GetViVoCategory() string
- func (m MessageType) GetViVoClassification() int64
- func (m MessageType) GetXiaoMiChannelId() string
- type PushClient
- func (g *PushClient) BindAlias(param *models.Alias) (resp *models.Response, err error)
- func (g *PushClient) BindTags(cid string, param *models.CustomTagsParam) (resp *models.Response, err error)
- func (g *PushClient) GetToken() (token string, err error)
- func (g *PushClient) GetUserCount(tags []*models.Tag) (resp *models.Response, err error)
- func (g *PushClient) PushAll(msgType, scheduleTime int, payload *models.CustomMessage) (resp *models.Response, err error)
- func (g *PushClient) PushAllByClient(msgType, scheduleTime int, clientType ClientType, ...) (resp *models.Response, err error)
- func (g *PushClient) PushAllByCustomTag(msgType, scheduleTime int, customTag []string, payload *models.CustomMessage) (resp *models.Response, err error)
- func (g *PushClient) PushAllByLogicTags(msgType, scheduleTime int, tags []*models.Tag, payload *models.CustomMessage) (resp *models.Response, err error)
- func (g *PushClient) PushAppByFastCustomTag(msgType, scheduleTime int, tag string, payload *models.CustomMessage) (resp *models.Response, err error)
- func (g *PushClient) PushListByCid(msgType int, cid []string, payload *models.CustomMessage) (data []*models.Response, err error)
- func (g *PushClient) PushSingleByAlias(msgType int, alias string, payload *models.CustomMessage) (resp *models.Response, err error)
- func (g *PushClient) PushSingleByCid(msgType int, cid string, payload *models.CustomMessage) (resp *models.Response, err error)
- func (g *PushClient) ReportPushTask(taskId string) (resp *models.Response, err error)
- func (g *PushClient) SearchAliasByCid(cid string) (resp *models.Response, err error)
- func (g *PushClient) SearchCidByAlias(alias string) (resp *models.Response, err error)
- func (g *PushClient) SearchStatus(cid string) (resp *models.Response, err error)
- func (g *PushClient) SearchTags(cid string) (resp *models.Response, err error)
- func (g *PushClient) SearchTaskDetailByCid(cid, taskId string) (resp *models.TaskDetailResp, err error)
- func (g *PushClient) SearchUser(cid string) (resp *models.Response, err error)
- func (g *PushClient) StopTask(taskId string) (resp *models.Response, err error)
- func (g *PushClient) UnBindAlias(param *models.Alias) (resp *models.Response, err error)
- func (g *PushClient) UnBindAllAlias(alias string) (resp *models.Response, err error)
- type PushConfig
- type PushStore
Constants ¶
const ( //APIURL 服务器地址 APIURL string = "https://restapi.getui.com/v2/" // NAME 日志中的前缀 NAME = "[个推]" // PublicChannel 运营推送 PublicChannel = 1 //公信通道 // PrivateChannel 聊天推送 PrivateChannel = 2 )
Variables ¶
var ( // TTL 消息存放时间 TTL = 86400000 // 1天: 1 * 24 * 3600 * 1000 )
var ( // ToDebug 全局的调试开关 ToDebug = false )
Functions ¶
func HttpRequest ¶
HttpRequest 请求API,返回 []byte
Types ¶
type ClientType ¶
type ClientType int
ClientType APP客户端类型
const ( Android ClientType = iota + 1 //android IOS //ios WechatAPP //微信小程序 )
type MessageType ¶ added in v0.0.9
type MessageType int
const ( ArticleMsg MessageType = iota + 1 AlgorithmReCommendMsg AttendRecommendMsg PlatformActionMsg UserAccountMsg InstantMsg )
func (MessageType) GetHonorImportance ¶ added in v0.0.9
func (m MessageType) GetHonorImportance() (importance string)
func (MessageType) GetHuaweiCategory ¶ added in v0.0.9
func (m MessageType) GetHuaweiCategory() string
GetHuaweiCategory 华为: 不同消息类型对应的category
func (MessageType) GetHuaweiChannelId ¶ added in v0.0.9
func (m MessageType) GetHuaweiChannelId() string
GetHuaweiChannelId 华为 channelId
func (MessageType) GetHuaweiImportance ¶ added in v0.0.9
func (m MessageType) GetHuaweiImportance() string
func (MessageType) GetHuaweiInfo ¶ added in v0.0.9
func (m MessageType) GetHuaweiInfo() (channelId, category, importance string)
GetHuaweiInfo 华为 channelId category
func (MessageType) GetOPPOChannelId ¶ added in v0.0.9
func (m MessageType) GetOPPOChannelId() string
func (MessageType) GetViVoCategory ¶ added in v0.0.9
func (m MessageType) GetViVoCategory() string
GetViVoCategory vivo: 不同消息类型对应的category
func (MessageType) GetViVoClassification ¶ added in v0.0.9
func (m MessageType) GetViVoClassification() int64
GetViVoClassification vivo: 不同消息类型对应的分类
func (MessageType) GetXiaoMiChannelId ¶ added in v0.0.9
func (m MessageType) GetXiaoMiChannelId() string
GetXiaoMiChannelId 小米: 不同消息类型对应的channelId
type PushClient ¶
type PushClient struct { *PushConfig *PushStore }
PushClient 个推 push client
func NewPushClient ¶
func NewPushClient(conf *PushConfig, store *PushStore, toDebug bool) (client *PushClient, err error)
NewPushClient 返回个推实例并初始化redis信息
func (*PushClient) BindTags ¶
func (g *PushClient) BindTags(cid string, param *models.CustomTagsParam) (resp *models.Response, err error)
BindTags 一个用户绑定一批标签
cid表示用户
func (*PushClient) GetToken ¶
func (g *PushClient) GetToken() (token string, err error)
GetToken 获取token
从redis中或api中获取
func (*PushClient) GetUserCount ¶ added in v0.0.2
GetUserCount 查询用户总量
func (*PushClient) PushAll ¶
func (g *PushClient) PushAll(msgType, scheduleTime int, payload *models.CustomMessage) (resp *models.Response, err error)
PushAll 推送给所有人
scheduleTime 定时推送时间戳,为0时,不定时
func (*PushClient) PushAllByClient ¶
func (g *PushClient) PushAllByClient(msgType, scheduleTime int, clientType ClientType, payload *models.CustomMessage) (resp *models.Response, err error)
PushAllByClient 推送给不同的客户端
clientType 客户端类型,只能选1种 scheduleTime 定时推送时间戳,为0时,不定时
func (*PushClient) PushAllByCustomTag ¶
func (g *PushClient) PushAllByCustomTag(msgType, scheduleTime int, customTag []string, payload *models.CustomMessage) (resp *models.Response, err error)
PushAllByCustomTag 对指定应用的符合筛选条件的用户群发推送消息。支持定时、定速功能
此接口频次限制100次/天,每分钟不能超过5次(推送限制和接口执行群推共享限制),定时推送功能需要申请开通才可以使用 scheduleTime 定时推送时间戳,为0时,不定时 customTag 内的标签是交集的关系
func (*PushClient) PushAllByLogicTags ¶ added in v0.0.2
func (g *PushClient) PushAllByLogicTags(msgType, scheduleTime int, tags []*models.Tag, payload *models.CustomMessage) (resp *models.Response, err error)
PushAllByLogicTags 对指定应用的符合筛选条件的用户群发推送消息。支持定时、定速功能
此接口频次限制100次/天,每分钟不能超过5次(推送限制和接口执行群推共享限制),定时推送功能需要申请开通才可以使用 scheduleTime 定时推送时间戳,为0时,不定时 tags为[]*models.Tag,需要自己构建tag表达式 see @https://docs.getui.com/getui/server/rest_v2/push/
func (*PushClient) PushAppByFastCustomTag ¶
func (g *PushClient) PushAppByFastCustomTag(msgType, scheduleTime int, tag string, payload *models.CustomMessage) (resp *models.Response, err error)
PushAppByFastCustomTag 使用标签快速推送
tag 为某一个标签名 scheduleTime 为定时任务的时间戳 此接口需要SVIP才有使用权限
func (*PushClient) PushListByCid ¶
func (g *PushClient) PushListByCid(msgType int, cid []string, payload *models.CustomMessage) (data []*models.Response, err error)
PushListByCid 按cid群推消息
当cid长度大于1000时,会分页循环进行推送
func (*PushClient) PushSingleByAlias ¶
func (g *PushClient) PushSingleByAlias(msgType int, alias string, payload *models.CustomMessage) (resp *models.Response, err error)
PushSingleByAlias 单推给某一个用户
alias = 用户的alias channelType = 通道类型
func (*PushClient) PushSingleByCid ¶
func (g *PushClient) PushSingleByCid(msgType int, cid string, payload *models.CustomMessage) (resp *models.Response, err error)
PushSingleByCid 单推给某一个用户
cid = 用户的cid信息 channelType = 通道类型
func (*PushClient) ReportPushTask ¶ added in v0.0.5
func (g *PushClient) ReportPushTask(taskId string) (resp *models.Response, err error)
ReportPushTask 获取推送结果(含自定义事件)可查询消息可下发数、下发数,接收数、展示数、点击数等结果
用于跟踪某个用户的消息到达情况
func (*PushClient) SearchAliasByCid ¶
func (g *PushClient) SearchAliasByCid(cid string) (resp *models.Response, err error)
SearchAliasByCid 按cid查别名
即这台设备上登录过哪些帐号
{"alias":"255617"}
func (*PushClient) SearchCidByAlias ¶
func (g *PushClient) SearchCidByAlias(alias string) (resp *models.Response, err error)
SearchCidByAlias 按alias查cid
即这个alias绑定过哪些设备
{ "cid": [ "1fb427ab8f93a6de4655f4a15add51d2", "699214926b118e9512a9330423fbaf5f" ] }
func (*PushClient) SearchStatus ¶
func (g *PushClient) SearchStatus(cid string) (resp *models.Response, err error)
SearchStatus 查询某个用户的状态,是否在线,上次在线时间等
根据cid查询
{ "294d4da8b52d909ed30d261baf91d2d2": { "last_login_time": "1663897775596", "status": "offline" } }
func (*PushClient) SearchTags ¶
func (g *PushClient) SearchTags(cid string) (resp *models.Response, err error)
SearchTags 查询某个用户已经绑定的标签
{ "7399c780f73ac4046d930dd2b4edf3b4": [ "VIP用户 文科 手机登录 本科二批 iOS guangdong" ] }
func (*PushClient) SearchTaskDetailByCid ¶
func (g *PushClient) SearchTaskDetailByCid(cid, taskId string) (resp *models.TaskDetailResp, err error)
SearchTaskDetailByCid 可以查询某任务下某cid的具体实时推送路径情况
用于跟踪某个用户的消息到达情况 此接口需要SVIP权限,暂时不可用
func (*PushClient) SearchUser ¶
func (g *PushClient) SearchUser(cid string) (resp *models.Response, err error)
SearchUser 查询用户信息
根据cid查询
{ "validCids": { "294d4da8b52d909ed30d261baf91d2d2": { "client_app_id": "7a4W8IrA3rAHxlJunzfTe", "package_name": "ymzy-dream-iOS", "device_token": "c2a73ad014d19111fef4454ebe19c811fd9c994f1e9f767318667adf9d0bbb69,,", "phone_type": 2, "phone_model": "iPhone14,2", "notification_switch": true, "create_time": "2022-03-03 14:10:46", "login_freq": 21, "brand": "iphone" } } }
func (*PushClient) StopTask ¶
func (g *PushClient) StopTask(taskId string) (resp *models.Response, err error)
StopTask 停止推送任务
对正处于推送状态,或者未接收的消息停止下发(只支持批量推和群推任务)
func (*PushClient) UnBindAllAlias ¶
func (g *PushClient) UnBindAllAlias(alias string) (resp *models.Response, err error)
UnBindAllAlias 解绑所有与该别名绑定的cid