Files
ylywyn eb0b869f6b 更新,完全支持V3
更新,完全支持V3
2015-07-04 02:23:52 +08:00

66 lines
915 B
Go

package jpushclient
import (
"errors"
)
const (
IOS = "ios"
ANDROID = "android"
WINPHONE = "winphone"
)
type Platform struct {
Os interface{}
osArry []string
}
func (this *Platform) All() {
this.Os = "all"
}
func (this *Platform) Add(os string) error {
if this.Os == nil {
this.osArry = make([]string, 0, 3)
} else {
switch this.Os.(type) {
case string:
panic("platform is all")
default:
}
}
//判断是否重复
for _, value := range this.osArry {
if os == value {
return nil
}
}
switch os {
case IOS:
fallthrough
case ANDROID:
fallthrough
case WINPHONE:
this.osArry = append(this.osArry, os)
this.Os = this.osArry
default:
return errors.New("unknow platform")
}
return nil
}
func (this *Platform) AddIOS() {
this.Add(IOS)
}
func (this *Platform) AddAndrid() {
this.Add(ANDROID)
}
func (this *Platform) AddWinphone() {
this.Add(WINPHONE)
}