Documentation
¶
Index ¶
Constants ¶
const ( ResponseErrorMissingRegistration = "MissingRegistration" ResponseErrorInvalidRegistration = "InvalidRegistration" ResponseErrorMismatchSenderID = "MismatchSenderId" ResponseErrorNotRegistered = "NotRegistered" ResponseErrorMessageTooBig = "MessageTooBig" ResponseErrorInvalidDataKey = "InvalidDataKey" ResponseErrorInvalidTTL = "InvalidTtl" ResponseErrorInternalServerError = "InternalServerError" ResponseErrorInvalidPackageName = "InvalidPackageName" )
const (
AndroidNotificationIcon = "ic_notification"
)
Variables ¶
This section is empty.
Functions ¶
func NewMessage ¶
func NewMessage(data map[string]string, notification *messaging.Notification, tokens ...string) *messaging.MulticastMessage
NewMessage returns a new Message with the specified payload and Token(s).
Types ¶
type JSONParseError ¶
type JSONParseError struct {
// contains filtered or unexported fields
}
type Sender ¶
Sender abstracts the interaction between the application server and the GCM server. The developer must obtain an API key from the Google APIs Console page and pass it to the Sender so that it can perform authorized requests on the application server's behalf. To send a message to one or more devices use the Sender's Send or SendNoRetry methods.
If Sender Client is nil, checkSender will automatically initialize a Client
func handler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
sender := &gcm.Sender{CredentialsJson: key}
/* ... */
}
func (*Sender) Send ¶
func (s *Sender) Send(msg *messaging.MulticastMessage, retries int) (*messaging.BatchResponse, []string, error)
Send sends a message to the GCM server, retrying in case of service unavailability. A non-nil error is returned if a non-recoverable error occurs (i.e. if the response status is not "200 OK").
Note that messages are retried using exponential backoff, and as a result, this method may block for several seconds.
func (*Sender) SendNoRetry ¶
func (s *Sender) SendNoRetry(msg *messaging.MulticastMessage) (*messaging.BatchResponse, []string, error)
SendNoRetry sends a message to the FCM server without retrying in case of service unavailability. A non-nil error is returned if a non-recoverable error occurs. If msg is a valid MulticastMessage, then the failed tokens will also be returned.
type UnauthorizedError ¶
type UnauthorizedError struct {
// contains filtered or unexported fields
}
type UnknownError ¶
type UnknownError struct {
// contains filtered or unexported fields
}