You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
2 years ago
|
package body
|
||
3 years ago
|
|
||
3 years ago
|
import (
|
||
2 years ago
|
"OpenIM/pkg/common/config"
|
||
3 years ago
|
)
|
||
3 years ago
|
|
||
3 years ago
|
type Notification struct {
|
||
3 years ago
|
Alert string `json:"alert,omitempty"`
|
||
|
Android Android `json:"android,omitempty"`
|
||
|
IOS Ios `json:"ios,omitempty"`
|
||
3 years ago
|
}
|
||
|
|
||
|
type Android struct {
|
||
3 years ago
|
Alert string `json:"alert,omitempty"`
|
||
3 years ago
|
Intent struct {
|
||
|
URL string `json:"url,omitempty"`
|
||
|
} `json:"intent,omitempty"`
|
||
3 years ago
|
Extras Extras `json:"extras"`
|
||
3 years ago
|
}
|
||
|
type Ios struct {
|
||
3 years ago
|
Alert string `json:"alert,omitempty"`
|
||
|
Sound string `json:"sound,omitempty"`
|
||
|
Badge string `json:"badge,omitempty"`
|
||
|
Extras Extras `json:"extras"`
|
||
|
MutableContent bool `json:"mutable-content"`
|
||
3 years ago
|
}
|
||
|
|
||
|
type Extras struct {
|
||
|
ClientMsgID string `json:"clientMsgID"`
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
func (n *Notification) SetAlert(alert string) {
|
||
3 years ago
|
n.Alert = alert
|
||
3 years ago
|
n.Android.Alert = alert
|
||
|
n.SetAndroidIntent()
|
||
|
n.IOS.Alert = alert
|
||
|
n.IOS.Sound = "default"
|
||
|
n.IOS.Badge = "+1"
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
func (n *Notification) SetExtras(extras Extras) {
|
||
|
n.IOS.Extras = extras
|
||
|
n.Android.Extras = extras
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
func (n *Notification) SetAndroidIntent() {
|
||
3 years ago
|
n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
func (n *Notification) IOSEnableMutableContent() {
|
||
|
n.IOS.MutableContent = true
|
||
|
}
|