notification

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

推送模块 目前仅整合APNS(IOS)、极光推送(Android)

IOS 推送模块

Android 推送模块

Index

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 NewAPNSClient

func NewAPNSClient() error

APNs Client

func NewJgClient

func NewJgClient() error

Jg Client

func PushToAndroid

func PushToAndroid(req PushNotification) bool

func PushToApp

func PushToApp(req PushNotification) bool

push messages to app

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 D

type D map[string]interface{}

type JgClient

type JgClient struct {
	MasterSecret string
	AppKey       string
	AuthCode     string
	BaseUrl      string
}

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 SectionAndroid struct {
	Enabled bool   `yaml:"enabled"`
	AppKey  string `yaml:"appkey"`
	Secret  string `yaml:"secret"`
}

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"`
}

type Sound

type Sound struct {
	Critical int     `json:"critical,omitempty"`
	Name     string  `json:"name,omitempty"`
	Volume   float32 `json:"volume,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL