define.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package oppo
  2. import "fmt"
  3. const (
  4. _host = "https://api.push.oppomobile.com"
  5. _apiAuth = _host + "/server/v1/auth"
  6. _apiMessage = _host + "/server/v1/message/notification/save_message_content" // 保存通知栏消息内容体
  7. _apiPushUnicast = _host + "/server/v1/message/notification/unicast" // 单条推送
  8. _apiPushBroadcast = _host + "/server/v1/message/notification/broadcast" // 批量推送
  9. // _apiStatistics = _host + "/server/v1/message/statistics" // 推送统计
  10. _callbackURL = "https://api.bilibili.com/x/push/callback/oppo"
  11. _authExpire = 24 * 60 * 60 // auth token 过期秒数
  12. // _pushTypeAll = "1" // 推送全部设备
  13. _pushTypeToken = "2" // 按token推
  14. // ResponseCodeServiceUnavalable service unavalable
  15. ResponseCodeServiceUnavalable = -1
  16. // ResponseCodeSuccess http normal response code
  17. ResponseCodeSuccess = 0
  18. // ResponseCodeInvalidToken invalid token response code
  19. ResponseCodeInvalidToken = 10000
  20. // ResponseCodeUnsubscribeToken unsubscribe token
  21. ResponseCodeUnsubscribeToken = 10001
  22. // ResponseCodeRepeatToken repeat token
  23. ResponseCodeRepeatToken = 10004
  24. // ActionTypeInner 打开应⽤内⻚(activity的intentaction)
  25. ActionTypeInner = 1
  26. )
  27. // Message message content.
  28. type Message struct {
  29. Title string `json:"title"`
  30. Content string `json:"content"`
  31. ActionType int `json:"click_action_type"` // 0:启动应⽤; 1:打开应⽤内⻚(activity的intentaction); 2:打开⽹⻚; 4:打开应⽤内⻚(activity); [⾮必填,默认值为0]
  32. ActionActivity string `json:"click_action_activity"` // 应⽤内⻚地址【click_action_type 为1或4时必填,⻓度500】
  33. ActionURL string `json:"click_action_url"` // ⽹⻚地址【click_action_type为2 必填,⻓度500】
  34. ActionParams string `json:"action_parameters"` // 传递给应⽤的参数,json格式
  35. OfflineTTL int `json:"off_line_ttl"` // 离线消息的存活时间 (默认3600s) (单位:秒), 【off_line值为true时,必填,最 ⻓10天】
  36. CallbackURL string `json:"call_back_url"` // 应⽤接收消息到达回执的回调(仅⽀持registrationId或aliasName 两种推送⽅式)
  37. }
  38. // Response push response.
  39. type Response struct {
  40. Code int `json:"code"`
  41. Message string `json:"message"`
  42. Data struct {
  43. MsgID string `json:"message_id,omitempty"`
  44. TaskID string `json:"task_id,omitempty"`
  45. TokenInvalid []string `json:"10000"`
  46. TokenUnsubscribe []string `json:"10001"`
  47. TokenRepeat []string `json:"10004"`
  48. } `json:"data"`
  49. }
  50. // Callback oppo callback.
  51. type Callback struct {
  52. MsgID string `json:"messageId"`
  53. TaskID string `json:"taskId"`
  54. Tokens string `json:"registrationIds"` // regId1, regid2
  55. EventType string `json:"eventType"` // push_arrive
  56. }
  57. // CallbackURL gets callback URL.
  58. func CallbackURL(app int64, task string) string {
  59. return fmt.Sprintf("%s?app=%d&task=%s", _callbackURL, app, task)
  60. }