github.com/tada-team/tdproto@v1.51.57/push_device_type.go (about)

     1  package tdproto
     2  
     3  type PushDeviceType int
     4  
     5  const (
     6  	PushDeviceAndroid = PushDeviceType(1)
     7  	PushDeviceIOS     = PushDeviceType(2)
     8  	PushDeviceWeb     = PushDeviceType(3)
     9  	PushDeviceSafari  = PushDeviceType(4)
    10  	PushDeviceIOSFB   = PushDeviceType(5)
    11  )
    12  
    13  var MobilePushDevices = []PushDeviceType{
    14  	PushDeviceAndroid,
    15  	PushDeviceIOSFB,
    16  	PushDeviceIOS,
    17  }
    18  
    19  var IOSPushDevices = []PushDeviceType{
    20  	PushDeviceIOS,
    21  	PushDeviceIOSFB,
    22  }
    23  
    24  var AndroidPushDevices = []PushDeviceType{
    25  	PushDeviceAndroid,
    26  }
    27  
    28  func (t PushDeviceType) DbValue() int16 {
    29  	return int16(t)
    30  }
    31  
    32  func (t PushDeviceType) String() string {
    33  	switch t {
    34  	case PushDeviceAndroid:
    35  		return "Android"
    36  	case PushDeviceIOS:
    37  		return "iOS"
    38  	case PushDeviceWeb:
    39  		return "web"
    40  	case PushDeviceSafari:
    41  		return "safari"
    42  	case PushDeviceIOSFB:
    43  		return "iOS-firebase"
    44  	default:
    45  		return "?"
    46  	}
    47  }
    48  
    49  func (t PushDeviceType) Mobile() bool {
    50  	for _, v := range MobilePushDevices {
    51  		if v == t {
    52  			return true
    53  		}
    54  	}
    55  	return false
    56  }
    57  
    58  func (t PushDeviceType) Name() string {
    59  	switch t {
    60  	case PushDeviceAndroid:
    61  		return "android"
    62  	case PushDeviceIOS:
    63  		return "ios"
    64  	case PushDeviceWeb:
    65  		return "web"
    66  	case PushDeviceSafari:
    67  		return "safari"
    68  	case PushDeviceIOSFB:
    69  		return "iosfb"
    70  	default:
    71  		return "?"
    72  	}
    73  }