|
|
@ -1,6 +1,9 @@
|
|
|
|
package requestBody
|
|
|
|
package requestBody
|
|
|
|
|
|
|
|
|
|
|
|
import "Open_IM/pkg/common/config"
|
|
|
|
import (
|
|
|
|
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Notification struct {
|
|
|
|
type Notification struct {
|
|
|
|
Alert string `json:"alert,omitempty"`
|
|
|
|
Alert string `json:"alert,omitempty"`
|
|
|
@ -15,11 +18,23 @@ type Android struct {
|
|
|
|
} `json:"intent,omitempty"`
|
|
|
|
} `json:"intent,omitempty"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
type Ios struct {
|
|
|
|
type Ios struct {
|
|
|
|
|
|
|
|
Alert string `json:"alert,omitempty"`
|
|
|
|
|
|
|
|
Sound string `json:"sound,omitempty"`
|
|
|
|
|
|
|
|
Badge string `json:"badge,omitempty"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (n *Notification) SetAlert(alert string) {
|
|
|
|
func (n *Notification) SetAlert(alert, platform string) {
|
|
|
|
n.Alert = alert
|
|
|
|
n.Alert = alert
|
|
|
|
|
|
|
|
switch platform {
|
|
|
|
|
|
|
|
case constant.AndroidPlatformStr:
|
|
|
|
n.Android.Alert = alert
|
|
|
|
n.Android.Alert = alert
|
|
|
|
|
|
|
|
n.SetAndroidIntent()
|
|
|
|
|
|
|
|
case constant.IOSPlatformStr:
|
|
|
|
|
|
|
|
n.IOS.Alert = alert
|
|
|
|
|
|
|
|
n.IOS.Sound = "default"
|
|
|
|
|
|
|
|
n.IOS.Badge = "+1"
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func (n *Notification) SetAndroidIntent() {
|
|
|
|
func (n *Notification) SetAndroidIntent() {
|
|
|
|
n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent
|
|
|
|
n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent
|
|
|
|