u_push

package
v0.0.0-...-59da782 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The user agent
	USER_AGENT = "Mozilla/5.0"
)

Variables

View Source
var (
	ROOT_KEYS = map[string]bool{
		"appkey":          true,
		"timestamp":       true,
		"type":            true,
		"device_tokens":   true,
		"alias":           true,
		"alias_type":      true,
		"file_id":         true,
		"filter":          true,
		"production_mode": true,
		"feedback":        true,
		"description":     true,
		"thirdparty_id":   true,
		"mipush":          true,
		"mi_activity":     true,
	}

	POLICY_KEYS = map[string]bool{
		"start_time":   true,
		"expire_time":  true,
		"max_send_num": true,
	}

	PAYLOAD_KEYS = map[string]bool{
		"display_type": true,
	}

	BODY_KEYS = map[string]bool{
		"ticker":       true,
		"title":        true,
		"text":         true,
		"builder_id":   true,
		"icon":         true,
		"largeIcon":    true,
		"img":          true,
		"play_vibrate": true,
		"play_lights":  true,
		"play_sound":   true,
		"sound":        true,
		"after_open":   true,
		"url":          true,
		"activity":     true,
		"custom":       true,
	}

	APS_KEYS = map[string]bool{
		"alert":             true,
		"badge":             true,
		"sound":             true,
		"content-available": true,
	}
)

Functions

This section is empty.

Types

type AfterOpenAction

type AfterOpenAction string
const (
	GO_APP      AfterOpenAction = "go_app"      //打开应用
	GO_URL      AfterOpenAction = "go_url"      //跳转到URL
	GO_ACTIVITY AfterOpenAction = "go_activity" //打开特定的activity
	GO_CUSTOM   AfterOpenAction = "go_custom"   //用户自定义内容。
)

type AndroidNotification

type AndroidNotification struct {
	*UmengNotification
}

func NewAndroidNotification

func NewAndroidNotification() *AndroidNotification

func (*AndroidNotification) GoActivityAfterOpen

func (t *AndroidNotification) GoActivityAfterOpen(activity string)

func (*AndroidNotification) GoAppAfterOpen

func (t *AndroidNotification) GoAppAfterOpen()

/点击"通知"的后续行为,默认为打开app。

func (*AndroidNotification) GoCustomAfterOpen

func (t *AndroidNotification) GoCustomAfterOpen(custom string)

func (*AndroidNotification) GoCustomAfterOpenJson

func (t *AndroidNotification) GoCustomAfterOpenJson(custom json.RawMessage)

func (*AndroidNotification) GoUrlAfterOpen

func (t *AndroidNotification) GoUrlAfterOpen(url string)

func (*AndroidNotification) SetBuilderId

func (t *AndroidNotification) SetBuilderId(builder_id int)

可选,默认为0,用于标识该通知采用的样式。使用该参数时, 必须在SDK里面实现自定义通知栏样式。

func (*AndroidNotification) SetDisplayType

func (t *AndroidNotification) SetDisplayType(d DisplayType)

必填,消息类型: notification(通知)、message(消息)

func (*AndroidNotification) SetExtraField

func (t *AndroidNotification) SetExtraField(key string, value interface{}) bool

Set extra key/value for Android notification

func (*AndroidNotification) SetIcon

func (t *AndroidNotification) SetIcon(icon string)

可选,状态栏图标ID,R.drawable.[smallIcon], 如果没有,默认使用应用图标。 图片要求为24*24dp的图标,或24*24px放在drawable-mdpi下。 注意四周各留1个dp的空白像素

func (*AndroidNotification) SetImg

func (t *AndroidNotification) SetImg(img string)

可选,通知栏大图标的URL链接。该字段的优先级大于largeIcon。该字段要求以http或者https开头。

func (*AndroidNotification) SetLargeIcon

func (t *AndroidNotification) SetLargeIcon(largeIcon string)

可选,通知栏拉开后左侧图标ID,R.drawable.[largeIcon], 图片要求为64*64dp的图标, 可设计一张64*64px放在drawable-mdpi下, 注意图片四周留空,不至于显示太拥挤

func (*AndroidNotification) SetMipush

func (t *AndroidNotification) SetMipush(enable bool, miActive string)

可选,默认为false。当为true时,表示MIUI、EMUI、Flyme系统设备离线转为系统下发 可选,mipush值为true时生效,表示走系统通道时打开指定页面acitivity的完整包路径。

func (*AndroidNotification) SetPlayLights

func (t *AndroidNotification) SetPlayLights(play_lights bool)

可选,收到通知是否闪灯,默认为"true"

func (*AndroidNotification) SetPlaySound

func (t *AndroidNotification) SetPlaySound(play_sound bool)

可选,收到通知是否发出声音,默认为"true"

func (*AndroidNotification) SetPlaySoundAndSound

func (t *AndroidNotification) SetPlaySoundAndSound(sound string)

/收到通知后播放指定的声音文件

func (*AndroidNotification) SetPlayVibrate

func (t *AndroidNotification) SetPlayVibrate(play_vibrate bool)

可选,收到通知是否震动,默认为"true"

func (*AndroidNotification) SetPredefinedKeyValue

func (t *AndroidNotification) SetPredefinedKeyValue(key string, value interface{}) bool

func (*AndroidNotification) SetSound

func (t *AndroidNotification) SetSound(sound string)

可选,通知声音,R.raw.[sound]. 如果该字段为空,采用SDK默认的声音 umeng_push_notification_default_sound声音文件。如果 SDK默认声音文件不存在,则使用系统默认Notification提示音。

func (*AndroidNotification) SetText

func (t *AndroidNotification) SetText(text string)

必填,通知文字描述

func (*AndroidNotification) SetTicker

func (t *AndroidNotification) SetTicker(ticker string)

必填,通知栏提示文字

func (*AndroidNotification) SetTitle

func (t *AndroidNotification) SetTitle(title string)

必填,通知标题

type DisplayType

type DisplayType string
const (
	NOTIFICATION DisplayType = "notification"
	MESSAGE      DisplayType = "message"
)

type IOSAlert

type IOSAlert struct {
	// 可为JSON类型
	Title    string `json:"title",omitempty`
	Subtitle string `json:"subtitle",omitempty`
	Body     string `json:"body",omitempty`
}

type IOSNotification

type IOSNotification struct {
	*UmengNotification
}

func NewIOSNotification

func NewIOSNotification() *IOSNotification

func (*IOSNotification) SetAlert

func (t *IOSNotification) SetAlert(token string)

func (*IOSNotification) SetAlertJson

func (t *IOSNotification) SetAlertJson(alert IOSAlert)

func (*IOSNotification) SetBadge

func (t *IOSNotification) SetBadge(badge int)

func (*IOSNotification) SetContentAvailable

func (t *IOSNotification) SetContentAvailable(contentAvailable int)

func (*IOSNotification) SetCustomizedField

func (t *IOSNotification) SetCustomizedField(key string, value interface{}) bool

Set customized key/value for IOS notification

func (*IOSNotification) SetPredefinedKeyValue

func (t *IOSNotification) SetPredefinedKeyValue(key string, value interface{}) bool

func (*IOSNotification) SetSound

func (t *IOSNotification) SetSound(sound string)

type PushClient

type PushClient struct {
}

func (*PushClient) Send

func (t *PushClient) Send(msg fieldSetter) error

func (*PushClient) UploadContents

func (t *PushClient) UploadContents(appkey, appMasterSecret, contents string) (string, error)

type UmengNotification

type UmengNotification struct {
	// contains filtered or unexported fields
}

func NewUmengNotification

func NewUmengNotification(f fieldSetter) *UmengNotification

func (*UmengNotification) SetAppMasterSecret

func (t *UmengNotification) SetAppMasterSecret(secret string)

func (*UmengNotification) SetDescription

func (t *UmengNotification) SetDescription(description string)

可选,发送消息描述,建议填写。

func (*UmengNotification) SetExpireTime

func (t *UmengNotification) SetExpireTime(expireTime string)

可选,消息过期时间,其值不可小于发送时间或者start_time(如果填写了的话), 如果不填写此参数,默认为3天后过期。格式同start_time

func (*UmengNotification) SetMaxSendNum

func (t *UmengNotification) SetMaxSendNum(num int)

可选,发送限速,每秒发送的最大条数。最小值1000 开发者发送的消息如果有请求自己服务器的资源,可以考虑此参数。

func (*UmengNotification) SetReleaseMode

func (t *UmengNotification) SetReleaseMode()

/正式模式

func (*UmengNotification) SetStartTime

func (t *UmengNotification) SetStartTime(startTime string)

可选,定时发送时,若不填写表示立即发送。格式: "YYYY-MM-DD hh:mm:ss"。

func (*UmengNotification) SetTestMode

func (t *UmengNotification) SetTestMode()

/测试模式

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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