Documentation ¶
Index ¶
- Constants
- Variables
- func GetAuthTokenIOS(authTokenPath string, keyID string, teamID string) (string, error)
- func GetAuthTokenV(appId, appKey, appSecret string) string
- type Alert
- type Android
- type AndroidNotification
- type Aps
- type AuthTokenResult
- type BadgeNotification
- type ClickAction
- type ClickTypeInfo
- type Data
- type ErrResult
- type Extra
- type GroupMessage
- type HW
- type HWFields
- type HWResult
- type IOS
- type IOSFields
- type IOSResult
- type MI
- type MIFields
- type MIResult
- type MZ
- type MZResult
- type Message
- type MessageFields
- type MessageJson
- type MessageNotification
- type MobileChannel
- type NoticeBarInfo
- type NoticeExpandInfo
- type Notification
- type OPPO
- type OPPONotification
- type OPPOResult
- type OPPOTokenData
- type OPPOTokenResult
- type Payload
- type PushTimeInfo
- type Response
- type ResultData
- type Send
- type TokenResult
- type VFieldGroup
- type VFieldSingle
- type VIVO
- type VResult
Constants ¶
View Source
const ( HTTPOK = 200 HTTPERROR = 500 SendSuccess = 0 SendError = 1 )
View Source
const ( HWProductionHost = "https://push-api.cloud.huawei.com/v1/" HWMessageURL = "/messages:send" HWTokenURL = "https://oauth-login.cloud.huawei.com/oauth2/v3/token" HWGrantType = "client_credentials" )
View Source
const ( HWSuccess = "80000000" HWPartTokenSendSuccess = "80100000" )
View Source
const ( IOSProductionHost = "https://api.development.push.apple.com" IOSMessageURL = "/3/device/" IOSTokenTimeout = 3000 )
View Source
const ( IOSSuccess = 200 // 成功 IOSErrorRequest = 400 // 错误的请求 IOSErrorAuthToken = 403 IOSErrorMethod = 405 IOSTimeOutDeviceToken = 410 IOSNotificationPayloadTooLarge = 413 IOSTooManyRequest = 429 IOSInternalServerError = 500 )
View Source
const ( MiProductionHost = "https://api.xmpush.xiaomi.com" MiMessageRegIdURL = "/v3/message/regid" MiMultiRegIdURL = "/v2/multi_messages/regids" )
View Source
const ( MiSuccess = 0 MiNetWorkErrorTimeOut = -1 )
View Source
const ( MZProductionHost = "http://server-api-push.meizu.com" MZMessageURL = "/garcia/api/server/push/varnished/pushByPushId" // pushId推送 MZToAppURL = "/garcia/api/server/push/pushTask/pushToApp" )
View Source
const ( MZSuccess = "200" MZOtherError = "500" MZSystemError = "1001" MZServerBusy = "1003" MZParamError = "1005" MZAuthTokenError = "1006" MZAppIdIllegal = "110000" MZAppKeyIllegal = "110001" MZParamEmpty = "110004" MZAppInBlackList = "110009" )
View Source
const ( OPPOProductionHost = "https://api.push.oppomobile.com" OPPOMessageURL = "/server/v1/message/notification/unicast_batch" // pushId推送 OPPOTokenURL = "/server/v1/auth" )
View Source
const ( OPPOSuccess = 0 OPPOServiceInFlowControl = -2 OPPOInvalidAuthToken = 11 OPPOHttpActionNotAllowed = 12 OPPOAppCallLimited = 13 )
View Source
const ( VIVOProductUrl = "https://api-push.vivo.com.cn" VIVOAuthUrl = "/message/auth" VIVOSingleSend = "/message/send" VIVOGroupTask = "/message/saveListPayload" VIVOGroupSend = "/message/pushToList" VIVOTokenTimeout = 3600 )
View Source
const ( VIVOSuccess = 0 V10050 = "alias和regId不能为空" V10051 = "暂不支持该消息类型" V10054 = "notifyType不合法" V10055 = "title不能为空" V10056 = "title不能超过40个字符串" )
View Source
const ( VIVOAuthSuccess = 0 VIVOAuthAppIdEmpty = 10200 VIVOAuthAppKeyEmpty = 10201 VIVOAuthAppKeyIllegal = 10202 VIVOAuthTimestampEmpty = 10203 VIVOAuthSignEmpty = 10204 VIVOAuthAppIdNotExist = 10205 VIVOAuthSignError = 10206 VIVOAuthTimestampIllegal = 10207 VIVOAuthExceededLimit = 10250 )
Variables ¶
View Source
var (
AvailableChannel = []string{"ios", "mi", "hw", "oppo", "vivo", "mz"}
)
Functions ¶
func GetAuthTokenIOS ¶
func GetAuthTokenV ¶
Types ¶
type Android ¶
type Android struct { CollapseKey int `json:"collapse_key"` // 缓存。0-只缓存新的一条,-1对所有离线消息都缓存、1-100分组缓存 Notification AndroidNotification `json:"notification"` }
type AndroidNotification ¶
type AndroidNotification struct { Title string `form:"title" json:"title"` Body string `form:"body" json:"body"` Icon string `json:"icon"` // 小图标 Tag string `json:"tag"` // 消息标签 ClickAction ClickAction `json:"click_action"` }
type AuthTokenResult ¶
type BadgeNotification ¶
type ClickAction ¶
type ClickTypeInfo ¶
type ClickTypeInfo struct { ClickType int `json:"clickType"` // 点击动作 0-打开应用(默认)、1-打开应用页面、2-打开URI页面、3-应用客户端自定义 Url string `json:"url"` // clickType=2时必填 Parameters map[string]string `json:"parameters"` // json 格式 非必填 Activity string `json:"activity"` // clickType=1时必填。格式:pkg.activity CustomAttribute string `json:"customAttribute"` // clickType=3时必填 }
type GroupMessage ¶
type GroupMessage struct { NotifyType int `json:"notifyType"` // 通知类型 1.无、2-响铃、3-振动、4-响铃和振动 Title string `json:"title"` Content string `json:"content"` TimeToLive int `json:"timeToLive"` // 消息保留时长 单位:秒,取值至少60秒,最长7天。当值为空时,默认一天 SkipType int `json:"skipType"` // 跳转类型。1-打开APP首页、2-打开链接、3-自定义、4-打开APP内指定页面 SkipContent string `json:"skipContent"` // 跳转类型为2时,跳转内容最大1000个字符,跳转类型为3或4时,跳转内容最大1024个字符,skipType传3需要在onNotificationMessageClicked回调函数中自己写处理逻辑 //ClientCustomMap string `json:"clientCustomMap"` // 客户端自定义键值对 RequestId string `json:"requestId"` // 消息唯一标识 }
type HW ¶
type HWFields ¶
type HWFields struct {
Message MessageNotification `json:"message"`
}
type IOS ¶
type MI ¶
type MIFields ¶
type MIFields struct { Payload string `json:"payload"` //消息内容 RestrictedPackageName string `json:"restricted_package_name"` //支持多包名 Title string `json:"title"` //在通知栏的标题,长度小于16 Description string `json:"description"` //在通知栏的描述,长度小于128 NotifyType string `json:"notify_type"` //通知类型 可组合 (-1 Default_all,1 Default_sound,2 Default_vibrate(震动),4 Default_lights) NotifyId string `json:"notify_id"` //同一个notifyId在通知栏只会保留一条 TimeToLive string `json:"time_to_live"` //可选项,当用户离线是,消息保留时间,默认两周,单位ms TimeToSend string `json:"time_to_send"` //可选项,定时发送消息,用自1970年1月1日以来00:00:00.0 UTC时间表示(以毫秒为单位的时间)。 Extra string `json:"extra"` }
type MIResult ¶
type MIResult struct { Code int64 `json:"code"` //0表示成功,非0表示失败 Result string `json:"result"` //"ok" 表示成功,"error" 表示失败 Description string `json:"description,omitempty"` //对发送消息失败原因的解释 Info string `json:"info,omitempty"` //详细信息 Reason string `json:"reason,omitempty"` //失败原因 Data *ResultData `json:"data,omitempty"` //本身就是一个json字符串 }
type Message ¶
type Message struct { Title string Desc string ApnsId string ClickType string ClickContent string Err error }
消息体
func NewMessage ¶
func NewMessage() *Message
func (*Message) SetClickContent ¶
func (*Message) SetClickType ¶
func (*Message) SetContent ¶
type MessageFields ¶
type MessageFields struct { TargetType int `json:"target_type"` TargetValue string `json:"target_value"` Notification OPPONotification `json:"notification"` }
type MessageJson ¶
type MessageJson struct { NoticeBarInfo NoticeBarInfo `json:"noticeBarInfo"` NoticeExpandInfo NoticeExpandInfo `json:"noticeExpandInfo"` ClickTypeInfo ClickTypeInfo `json:"clickTypeInfo"` PushTimeInfo PushTimeInfo `json:"pushTimeInfo"` }
type MessageNotification ¶
type MessageNotification struct { Notification Notification `form:"notification" json:"notification"` Android Android `form:"android" json:"android"` Token []string `json:"token"` }
type MobileChannel ¶
type NoticeBarInfo ¶
type NoticeExpandInfo ¶
type Notification ¶
type OPPONotification ¶
type OPPONotification struct { AppMessageId string `json:"app_message_id"` // 消息tag Style int `json:"style"` // 1-标准样式(默认1) 2-长文本 3-大图 BigPictureId string `json:"big_picture_id"` // 大图id SmallPictureId string `json:"small_picture_id"` // 图标 Title string `json:"title"` SubTitle string `json:"sub_title"` Content string `json:"content"` ClickActionType int `json:"click_action_type"` //点击动作类型0,启动应用;1,打开应用内页(activity的intent action);2,打开网页;4,打开应用内页(activity);【非必填,默认值为0】;5,Intent scheme URL ClickActionActivity string `json:"click_action_activity"` // 应用内页地址【click_action_type为1/4/ 时必填,长度500】 ClickActionUrl string `json:"click_action_url"` // 网页地址或【click_action_type为2与5时必填 ActionParameters string `json:"action_parameters"` // 传递给网页或应用的参数 json 格式 }
type OPPOResult ¶
type OPPOTokenData ¶
type OPPOTokenResult ¶
type OPPOTokenResult struct { Code int `json:"code"` Message string `json:"message"` Data OPPOTokenData `json:"data"` }
type Payload ¶
type Payload struct { PushTitle string `json:"push_title"` PushBody string `json:"push_body"` IsShowNotify string `json:"is_show_notify"` Ext string `json:"ext"` }
消息payload,根据业务自定义
type PushTimeInfo ¶
type ResultData ¶
type Send ¶
func (*Send) SetPlatForm ¶
type TokenResult ¶
type VFieldGroup ¶
type VFieldSingle ¶
type VFieldSingle struct { RegId string `json:"regId"` NotifyType int `json:"notifyType"` // 通知类型 1.无、2-响铃、3-振动、4-响铃和振动 Title string `json:"title"` Content string `json:"content"` TimeToLive int `json:"timeToLive"` // 消息保留时长 单位:秒,取值至少60秒,最长7天。当值为空时,默认一天 SkipType int `json:"skipType"` // 跳转类型。1-打开APP首页、2-打开链接、3-自定义、4-打开APP内指定页面 SkipContent string `json:"skipContent"` // 跳转类型为2时,跳转内容最大1000个字符,跳转类型为3或4时,跳转内容最大1024个字符,skipType传3需要在onNotificationMessageClicked回调函数中自己写处理逻辑 //ClientCustomMap string `json:"clientCustomMap"` // 客户端自定义键值对 RequestId string `json:"requestId"` // 消息唯一标识 }
Click to show internal directories.
Click to hide internal directories.