/xiaomi-push

小米推送 golang sdk

Primary LanguageGo

xiaomi-push

小米推送服务 Golang SDK

Production ready, full golang implementation of Xiaomi Push API (http://dev.xiaomi.com/console/?page=appservice&mod=push)

var client = xiaomipush.NewClient("yourappSecret", []string{"packageName"})

func main() {
    var msg1 *Message = xiaomipush.NewAndroidMessage("title", "body").SetPayload("this is payload1")
    client.Send(context.Background(), msg1, regID1)
}

Sender APIs

  • Send(msg *Message, regID string)
  • SendToList(msg *Message, regIDList []string)
  • SendTargetMessageList(msgList []*TargetedMessage)
  • SendToAlias(msg *Message, alias string)
  • SendToAliasList(msg *Message, aliasList []string)
  • SendToUserAccount(msg *Message, userAccount string)
  • SendToUserAccountList(msg *Message, accountList []string)
  • Broadcast(msg *Message, topic string)
  • BroadcastAll(msg *Message) (*SendResult, error)
  • MultiTopicBroadcast(msg *Message, topics []string, topicOP TopicOP)
  • CheckScheduleJobExist(msgID string)
  • DeleteScheduleJob(msgID string) (*Result, error)
  • DeleteScheduleJobByJobKey(jobKey string) (*Result, error)

Stats APIs

  • Stats(start, end, packageName string)
  • GetMessageStatusByMsgID(msgID string) (*SingleStatusResult, error)
  • GetMessageStatusByJobKey(jobKey string) (*BatchStatusResult, error)
  • GetMessageStatusPeriod(beginTime, endTime int64) (*BatchStatusResult, error)

Subscription APIs

  • SubscribeTopicForRegID(regID, topic, category string) (*Result, error)
  • SubscribeTopicForRegIDList(regIDList []string, topic, category string) (*Result, error)
  • UnSubscribeTopicForRegID(regID, topic, category string) (*Result, error)
  • UnSubscribeTopicForRegIDList(regIDList []string, topic, category string) (*Result, error)
  • SubscribeTopicByAlias(aliases []string, topic, category string) (*Result, error)
  • UnSubscribeTopicByAlias(aliases []string, topic, category string) (*Result, error)

Feedback APIs

  • GetInvalidRegIDs() (*InvalidRegIDsResult, error)

DevTools APIs

  • GetAliasesOfRegID(regID string) (*AliasesOfRegIDResult, error)
  • GetTopicsOfRegID(regID string) (*TopicsOfRegIDResult, error)