mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-03 00:12:48 +08:00
push
This commit is contained in:
parent
6bf0a3a804
commit
fb72f4b1ae
@ -88,8 +88,9 @@ type PushReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Ios struct {
|
type Ios struct {
|
||||||
NotiType *string `json:"type"`
|
NotiType *string `json:"type"`
|
||||||
Aps struct {
|
AutoBadge *string `json:"auto_badge"`
|
||||||
|
Aps struct {
|
||||||
Sound string `json:"sound"`
|
Sound string `json:"sound"`
|
||||||
Alert Alert `json:"alert"`
|
Alert Alert `json:"alert"`
|
||||||
} `json:"aps"`
|
} `json:"aps"`
|
||||||
@ -158,26 +159,22 @@ func (g *Getui) Push(userIDList []string, title, detailContent, operationID stri
|
|||||||
ChannelID: config.Config.Push.Getui.ChannelID,
|
ChannelID: config.Config.Push.Getui.ChannelID,
|
||||||
ChannelName: config.Config.Push.Getui.ChannelName,
|
ChannelName: config.Config.Push.Getui.ChannelName,
|
||||||
}}}
|
}}}
|
||||||
|
pushReq.setPushChannel(title, detailContent)
|
||||||
pushResp := PushResp{}
|
pushResp := PushResp{}
|
||||||
if len(userIDList) > 1 {
|
if len(userIDList) > 1 {
|
||||||
taskID, err := g.GetTaskID(operationID, token, pushReq)
|
taskID, err := g.GetTaskID(operationID, token, pushReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", utils.Wrap(err, "GetTaskIDAndSave2Redis failed")
|
return "", utils.Wrap(err, "GetTaskIDAndSave2Redis failed")
|
||||||
}
|
}
|
||||||
|
pushReq = PushReq{Audience: &Audience{Alias: userIDList}}
|
||||||
var IsAsync = false
|
var IsAsync = false
|
||||||
pushReq.IsAsync = &IsAsync
|
pushReq.IsAsync = &IsAsync
|
||||||
pushReq.Taskid = &taskID
|
pushReq.Taskid = &taskID
|
||||||
pushReq.PushMessage = nil
|
|
||||||
pushReq.Audience = &Audience{Alias: userIDList}
|
|
||||||
pushReq.setPushChannel(title, detailContent)
|
|
||||||
err = g.request(BatchPushURL, pushReq, token, &pushResp, operationID)
|
err = g.request(BatchPushURL, pushReq, token, &pushResp, operationID)
|
||||||
} else {
|
} else {
|
||||||
reqID := utils.OperationIDGenerator()
|
reqID := utils.OperationIDGenerator()
|
||||||
pushReq.RequestID = &reqID
|
pushReq.RequestID = &reqID
|
||||||
pushReq.Audience = &Audience{Alias: []string{userIDList[0]}}
|
pushReq.Audience = &Audience{Alias: []string{userIDList[0]}}
|
||||||
pushReq.setPushChannel(title, detailContent)
|
|
||||||
notify := "notify"
|
|
||||||
pushReq.PushChannel.Ios.NotiType = ¬ify
|
|
||||||
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
||||||
}
|
}
|
||||||
switch err {
|
switch err {
|
||||||
@ -267,7 +264,10 @@ func (g *Getui) request(url string, content interface{}, token string, returnStr
|
|||||||
|
|
||||||
func (pushReq *PushReq) setPushChannel(title string, body string) {
|
func (pushReq *PushReq) setPushChannel(title string, body string) {
|
||||||
pushReq.PushChannel = &PushChannel{}
|
pushReq.PushChannel = &PushChannel{}
|
||||||
pushReq.PushChannel.Ios = &Ios{}
|
autoBadge := "+1"
|
||||||
|
pushReq.PushChannel.Ios = &Ios{AutoBadge: &autoBadge}
|
||||||
|
notify := "notify"
|
||||||
|
pushReq.PushChannel.Ios.NotiType = ¬ify
|
||||||
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
||||||
pushReq.PushChannel.Ios.Aps.Alert = Alert{
|
pushReq.PushChannel.Ios.Aps.Alert = Alert{
|
||||||
Title: title,
|
Title: title,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user