Add type Platform.
This commit is contained in:
parent
952ede1d39
commit
137f53a84d
|
@ -0,0 +1,51 @@
|
|||
package push_common
|
||||
|
||||
type Platform int
|
||||
|
||||
const (
|
||||
PlatformUnknown Platform = 0
|
||||
PlatformIos Platform = 1
|
||||
PlatformAndroid Platform = 2
|
||||
PlatformAmazon Platform = 3
|
||||
PlatformSamsung Platform = 4
|
||||
PlatformHuawei Platform = 5
|
||||
)
|
||||
|
||||
func PlatformToString(p Platform) string {
|
||||
switch p {
|
||||
case PlatformUnknown:
|
||||
return "unknown"
|
||||
case PlatformIos:
|
||||
return "ios"
|
||||
case PlatformAndroid:
|
||||
return "android"
|
||||
case PlatformAmazon:
|
||||
return "amazon"
|
||||
case PlatformSamsung:
|
||||
return "samsung"
|
||||
case PlatformHuawei:
|
||||
return "huawei"
|
||||
}
|
||||
return "error"
|
||||
}
|
||||
|
||||
// Когда в pushd добавляется транспорт для новой платформы,
|
||||
// то эту платформу нужно указать в этой функции.
|
||||
func GetSupportedPlatforms() []Platform {
|
||||
return []Platform{
|
||||
PlatformIos,
|
||||
PlatformAndroid,
|
||||
//PlatformAmazon,
|
||||
PlatformSamsung,
|
||||
PlatformHuawei,
|
||||
}
|
||||
}
|
||||
|
||||
func PlatformsContain(platforms []Platform, p Platform) bool {
|
||||
for _, item := range platforms {
|
||||
if item == p {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Loading…
Reference in New Issue