platform.go 587 B

12345678910111213141516171819202122232425262728293031323334
  1. package jpush
  2. const (
  3. // PlatformIOS .
  4. PlatformIOS = "ios"
  5. // PlatformAndroid .
  6. PlatformAndroid = "android"
  7. // PlatformWinphone .
  8. PlatformWinphone = "winphone"
  9. // PlatformAll .
  10. PlatformAll = "all"
  11. )
  12. // Platform .
  13. type Platform struct {
  14. OS interface{}
  15. osArray []string
  16. }
  17. // NewPlatform .
  18. func NewPlatform(os ...string) *Platform {
  19. p := new(Platform)
  20. for _, v := range os {
  21. switch v {
  22. case PlatformIOS, PlatformAndroid, PlatformWinphone:
  23. p.osArray = append(p.osArray, v)
  24. case PlatformAll:
  25. p.OS = PlatformAll
  26. return p
  27. }
  28. }
  29. p.OS = p.osArray
  30. return p
  31. }