Documentation ¶
Overview ¶
推送模块 目前仅整合APNS(IOS)、极光推送(Android)
IOS 推送模块 ¶
Android 推送模块
Index ¶
- Constants
- Variables
- func GetIOSNotification(req PushNotification) *apns2.Notification
- func NewAPNSClient() error
- func NewJgClient() error
- func PushToAndroid(req PushNotification) bool
- func PushToApp(req PushNotification) bool
- func PushToIOS(req PushNotification) bool
- type Alert
- type D
- type JgClient
- type NotificationConfig
- type PlatformType
- type PushNotification
- type RequestPush
- type SectionAndroid
- type SectionIos
- type Sound
Constants ¶
View Source
const ( ApnsPriorityLow = 5 ApnsPriorityHigh = 10 )
Variables ¶
View Source
var ( Config NotificationConfig // 配置文件 支持yaml、json 导入 ApnsClient *apns2.Client // Apns(IOS)推送实例 AndroidClient *jpushclient.PushClient // 极光(Android)推送实例 )
Functions ¶
func GetIOSNotification ¶
func GetIOSNotification(req PushNotification) *apns2.Notification
func PushToAndroid ¶
func PushToAndroid(req PushNotification) bool
func PushToIOS ¶
func PushToIOS(req PushNotification) bool
Types ¶
type Alert ¶
type Alert struct { Action string `json:"action,omitempty"` ActionLocKey string `json:"action-loc-key,omitempty"` Body string `json:"body,omitempty"` LaunchImage string `json:"launch-image,omitempty"` LocArgs []string `json:"loc-args,omitempty"` LocKey string `json:"loc-key,omitempty"` Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` TitleLocArgs []string `json:"title-loc-args,omitempty"` TitleLocKey string `json:"title-loc-key,omitempty"` }
type NotificationConfig ¶
type NotificationConfig struct { Android SectionAndroid Ios SectionIos }
推送配置
type PlatformType ¶
type PlatformType string
var ( PlatformAndroid PlatformType = "android" PlatformIos PlatformType = "ios" )
type PushNotification ¶
type PushNotification struct { // Common Tokens []string `json:"tokens" binding:"required"` Platform PlatformType `json:"platform" binding:"required"` Message string `json:"message,omitempty"` Title string `json:"title,omitempty"` Priority string `json:"priority,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` MutableContent bool `json:"mutable_content,omitempty"` Sound interface{} `json:"sound,omitempty"` Data D `json:"data,omitempty"` Retry int `json:"retry,omitempty"` // iOS Expiration int64 `json:"expiration,omitempty"` ApnsID string `json:"apns_id,omitempty"` CollapseID string `json:"collapse_id,omitempty"` Topic string `json:"topic,omitempty"` Badge *int `json:"badge,omitempty"` Category string `json:"category,omitempty"` ThreadID string `json:"thread-id,omitempty"` URLArgs []string `json:"url-args,omitempty"` Alert Alert `json:"alert,omitempty"` Production bool `json:"production,omitempty"` Development bool `json:"development,omitempty"` SoundName string `json:"name,omitempty"` SoundVolume float32 `json:"volume,omitempty"` // contains filtered or unexported fields }
func (*PushNotification) AddWaitCount ¶
func (p *PushNotification) AddWaitCount()
func (*PushNotification) WaitDone ¶
func (p *PushNotification) WaitDone()
type RequestPush ¶
type RequestPush struct {
Notifications []PushNotification `json:"notifications" binding:"required"`
}
type SectionAndroid ¶
type SectionIos ¶
type SectionIos struct { Enabled bool `yaml:"enabled" json:"enabled"` KeyPath string `yaml:"key_path" json:"key_path"` KeyBase64 string `yaml:"key_base64" json:"key_base64"` KeyType string `yaml:"key_type" json:"key_type"` Password string `yaml:"password" json:"password"` Production bool `yaml:"production" json:"production"` MaxRetry int `yaml:"max_retry" json:"max_retry"` KeyID string `yaml:"key_id" json:"key_id"` TeamID string `yaml:"team_id" json:"team_id"` }
Click to show internal directories.
Click to hide internal directories.