1
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestAscriptionPlace(t *testing.T) {
|
func TestAscriptionPlace(t *testing.T) {
|
||||||
p, err := Find("13146872779")
|
p, err := Find("17146563473")
|
||||||
fmt.Println(p)
|
fmt.Println(p)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package uinapp
|
package uinapp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"fmt"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -18,55 +17,45 @@ func TestGetToken(t *testing.T) {
|
|||||||
globals.SugarLogger.Debug("result := %v", err)
|
globals.SugarLogger.Debug("result := %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSendMsgAndroid(t *testing.T) {
|
func TestCidSend(t *testing.T) {
|
||||||
api.SendMsgByUinApp(SendMsgReq{
|
err := api.SendMsgByUinApp(map[string]interface{}{
|
||||||
RequestId: utils.Int64ToStr(time.Now().UnixNano()),
|
"request_id": "12345237568ydfd2",
|
||||||
GroupName: "",
|
"settings": map[string]interface{}{
|
||||||
Audience: AudienceCid{CId: []string{android}},
|
"ttl": 7200000,
|
||||||
Settings: SendMsgSetting{},
|
},
|
||||||
PushMessage: PushMessageDetail{
|
"audience": map[string]interface{}{
|
||||||
Notification: PushMessageDetailNotification{
|
"cid": []string{"808ba3cebba05782f82063d590b738a3"},
|
||||||
Title: "测试消息推送[个推推送消息参数]",
|
},
|
||||||
Body: "吃早饭了没得[个推推送消息参数]",
|
"push_message": map[string]interface{}{
|
||||||
BigText: "这是个什么东西[个推推送消息参数]",
|
"transmission": "{'type':'new','title':'火车南站店','content':'老板,您来新订单了,请尽快接单!'}",
|
||||||
BigImage: "",
|
},
|
||||||
Logo: "",
|
"push_channel": map[string]interface{}{
|
||||||
LogoUrl: "",
|
"android": map[string]interface{}{
|
||||||
ChannelId: "",
|
"ups": map[string]interface{}{
|
||||||
ChannelName: "",
|
"transmission": "厂商透传消息",
|
||||||
ChannelLevel: 0,
|
},
|
||||||
ClickType: "startapp",
|
},
|
||||||
Intent: "",
|
"ios": map[string]interface{}{
|
||||||
Url: "",
|
"type": "notify",
|
||||||
Payload: "",
|
"payload": "{'type':'new','title':'火车南站店','content':'老板,您来新订单了,请尽快接单!'}",
|
||||||
NotifyId: 0,
|
"aps": map[string]interface{}{
|
||||||
RingName: "",
|
"alert": map[string]interface{}{
|
||||||
BadgeAddNum: 0,
|
"title": "火车南站店",
|
||||||
ThreadId: "",
|
"body": "新订单",
|
||||||
|
},
|
||||||
|
"content-available": 0,
|
||||||
|
"sound": "自定义铃声,设置为包含后缀名的完整文件名,示例值:ring.mp3",
|
||||||
|
"category": "在客户端通知栏触发特定的action和button显示",
|
||||||
|
},
|
||||||
|
"auto_badge": "+1",
|
||||||
|
"multimedia": []map[string]interface{}{
|
||||||
|
{
|
||||||
|
"url": "https://xxx",
|
||||||
|
"type": 1,
|
||||||
|
"only_wifi": false},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
PushChannel: PushChannelDetail{
|
|
||||||
//Ios: IosApsDetail{},
|
|
||||||
Android: AndroidPushChannelDetail{Ups: AndroidPushChannelUps{
|
|
||||||
Notification: AndroidPushChannelNotification{
|
|
||||||
Title: "测试消息推送[厂商推送消息参数]",
|
|
||||||
Body: "吃早饭了没得[厂商推送消息参数]",
|
|
||||||
ClickType: "startapp",
|
|
||||||
Intent: "",
|
|
||||||
Url: "",
|
|
||||||
NotifyId: 0,
|
|
||||||
},
|
|
||||||
Transmission: "",
|
|
||||||
Revoke: struct {
|
|
||||||
OldTaskId string `json:"old_task_id"`
|
|
||||||
}{},
|
|
||||||
Options: struct {
|
|
||||||
Constraint string `json:"constraint"`
|
|
||||||
Key string `json:"key"`
|
|
||||||
Value interface{} `json:"value"`
|
|
||||||
}{},
|
|
||||||
}},
|
|
||||||
Mp: MpPushChannelDetail{},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,17 +109,19 @@ type IosPushChannelAps struct {
|
|||||||
ContentState struct{} `json:"content-state"` // type为liveactivity时必填
|
ContentState struct{} `json:"content-state"` // type为liveactivity时必填
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MultimediaIos struct {
|
||||||
|
Url string `json:"url"` // 多媒体资源地址
|
||||||
|
TypeMultimedia int64 `json:"type"` // 资源类型(1.图片,2.音频,3.视频)
|
||||||
|
OnlyWifi bool `json:"only_wifi"` // 是否只在wifi环境下加载,如果设置成true,但未使用wifi时,会展示成普通通知
|
||||||
|
}
|
||||||
|
|
||||||
type IosApsDetail struct {
|
type IosApsDetail struct {
|
||||||
NotifyType string `json:"type"` // notify默认通知消息 voip:voip语音推送,notify:apns通知消息,liveactivity:灵动岛推送(不支持p12证书)
|
NotifyType string `json:"type"` // notify默认通知消息 voip:voip语音推送,notify:apns通知消息,liveactivity:灵动岛推送(不支持p12证书)
|
||||||
Aps IosPushChannelAps `json:"aps"` // 推送通知消息内容
|
Aps IosPushChannelAps `json:"aps"` // 推送通知消息内容
|
||||||
AutoBadge string `json:""` // 用于计算icon上显示的数字,还可以实现显示数字的自动增减,如“+1”、 “-1”、 “1” 等,计算结果将覆盖badge
|
AutoBadge string `json:""` // 用于计算icon上显示的数字,还可以实现显示数字的自动增减,如“+1”、 “-1”、 “1” 等,计算结果将覆盖badge
|
||||||
Payload string `json:"payload"` // 增加自定义的数据
|
Payload string `json:"payload"` // 增加自定义的数据
|
||||||
Multimedia []struct { // 多媒体设置
|
Multimedia []MultimediaIos `json:"multimedia"` // 多媒体设置
|
||||||
Url string `json:"url"` // 多媒体资源地址
|
ApnsCollapseId string `json:"apns-collapse-id"` // 使用相同的apns-collapse-id可以覆盖之前的消息
|
||||||
TypeMultimedia int64 `json:"type"` // 资源类型(1.图片,2.音频,3.视频)
|
|
||||||
OnlyWifi bool `json:"only_wifi"` // 是否只在wifi环境下加载,如果设置成true,但未使用wifi时,会展示成普通通知
|
|
||||||
} `json:"multimedia"` // 多媒体设置
|
|
||||||
ApnsCollapseId string `json:"apns-collapse-id"` // 使用相同的apns-collapse-id可以覆盖之前的消息
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AndroidPushChannelUps struct {
|
type AndroidPushChannelUps struct {
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package uinapp
|
package uinapp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendMsgRes struct {
|
type SendMsgRes struct {
|
||||||
@@ -16,13 +19,16 @@ type SendMsgRes struct {
|
|||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) SendMsgByUinApp(parma SendMsgReq) error {
|
func (a *API) SendMsgByUinApp(parma map[string]interface{}) error {
|
||||||
if err := a.CheckTokenIsExpire(); err != nil {
|
if err := a.CheckTokenIsExpire(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := a.AccessAPI(BaseUrl+a.appId, PushMsgByCid, http.MethodPost, utils.Struct2MapByJson(parma))
|
data, _ := json.Marshal(parma)
|
||||||
if err != nil {
|
fmt.Println(string(data))
|
||||||
|
result, err := a.AccessAPI(BaseUrl+a.appId, PushMsgByCid, http.MethodPost, parma)
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
if err != nil && !strings.Contains(err.Error(), "success") {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +36,7 @@ func (a *API) SendMsgByUinApp(parma SendMsgReq) error {
|
|||||||
if err := utils.Map2StructByJson(result, &sendMsgRes, false); err != nil {
|
if err := utils.Map2StructByJson(result, &sendMsgRes, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if sendMsgRes.Code != 200 {
|
if sendMsgRes.Code != 0 {
|
||||||
return errors.New(sendMsgRes.Msg)
|
return errors.New(sendMsgRes.Msg)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user