Documentation ¶
Index ¶
- Constants
- func Confirm() <-chan *ApnsMessage
- func Feedback() *feedback
- func Init(cfg Config) error
- func NewAlertDictionary() *alertDictionary
- func NewNotification() *notification
- func Send(payload PayloadInterface, deviceToken string) (messageIdentification uint32)
- func SetGoLogger(logger *log.Logger)
- func SetLogger(logger Logger)
- type ApnsMessage
- type Config
- type FeedbackMessage
- type Logger
- type PayloadInterface
- type PushNotification
- func (pn *PushNotification) Config() (expiration uint32, priority uint8)
- func (pn *PushNotification) SetCustom(key string, value interface{})
- func (pn *PushNotification) SetExpire(expire time.Duration)
- func (pn *PushNotification) SetNotification(n *notification)
- func (pn *PushNotification) SetPriority(priority uint8)
- func (pn *PushNotification) ToJson() (data []byte, err error)
Constants ¶
const ( SANDBOX_GATEWAY = "gateway.sandbox.push.apple.com:2195" PRODUCTION_GATEWAY = "gateway.push.apple.com:2195" SANDBOX_FEEDBACK_GATEWAY = "feedback.push.apple.com:2196" PRODUCTION_FEEDBACK_GATEWAY = "feedback.sandbox.push.apple.com:2196" )
const (
MaxNotificationSizeBytes = 2048 //max notification data size (2K)
)
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
func Confirm() <-chan *ApnsMessage
you will receive the message sent status on this channel on error the SetError will be called on the payload and with that you can check the why and if it has failed you must read the confirm or after MessageQueueSize messages will block start blocking the error will be the last error from the retry confirm is safe to be called from multiple go rutines
func Feedback ¶
func Feedback() *feedback
this method will start the feedback service and is returning an object with 3 methods Channel, Interval and Stop on Channel you will recevie all the feedback messages Interval check at each interval for new messages Interval is default 0, this will make it do only one request then will stop, if interval > 0 then at each interval will check for new message (the timer is started when you request the channel) after Stop make sure you read until channel close so you get all the messages
func NewAlertDictionary ¶
func NewAlertDictionary() *alertDictionary
func NewNotification ¶
func NewNotification() *notification
func Send ¶
func Send(payload PayloadInterface, deviceToken string) (messageIdentification uint32)
send a apns message, 0 and max uint32 id's are reserved, don't use them the status of the payload must be read from Confirmation channel you must read the confirm or after MessageQueueSize messages will block start blocking sent is safe to be called from multiple go rutines
func SetGoLogger ¶
Types ¶
type ApnsMessage ¶
type ApnsMessage struct { PayloadInterface DeviceToken string Error error // contains filtered or unexported fields }
func (*ApnsMessage) SetStatus ¶
func (a *ApnsMessage) SetStatus(err error, permanentError bool)
type Config ¶
type Config struct { SuccessTimeout time.Duration //the duration after that a message without response will be considered success MaxMessageRetry uint //max times to retry and send a message before we reported as failed MessageQueueSize uint //max number of messages that are going to be in the send/confirm and feedback channel //note that the channel will block if is going to be full NotificationPriority uint8 // the default priority is 10 (if alert/sound/badge not set, will be forced to 5) NotificationExpiration time.Duration // the default duration after wich apple will expire the notif IsProduction bool //should i use production or sandbox enviroment ? Certificate string //inline certificate or file path (note certificate and the key must be the same file or inline) CertificateKey string //inline certificate key or file path ReconnectDistanceTime time.Duration //the min distance to reconnect a failed connection MinPoolSize uint //min connection pool size MaxPoolSize uint //max connection pool size UpgradePool uint //the number of messages in the queue (for 10s) after wich the pool will be upgraded DowngradePool uint //the number of messages in the queue (for 5 min) after wich the poll will be downgraded ReportingInterval time.Duration //the interval between to reports FeedbackReadTimeout time.Duration //how long to wait for messages on a connection // contains filtered or unexported fields }
type FeedbackMessage ¶
type PayloadInterface ¶
type PushNotification ¶
type PushNotification struct {
// contains filtered or unexported fields
}
func NewPushNotification ¶
func NewPushNotification() *PushNotification
func (*PushNotification) Config ¶
func (pn *PushNotification) Config() (expiration uint32, priority uint8)
func (*PushNotification) SetCustom ¶
func (pn *PushNotification) SetCustom(key string, value interface{})
func (*PushNotification) SetExpire ¶
func (pn *PushNotification) SetExpire(expire time.Duration)
func (*PushNotification) SetNotification ¶
func (pn *PushNotification) SetNotification(n *notification)
func (*PushNotification) SetPriority ¶
func (pn *PushNotification) SetPriority(priority uint8)
func (*PushNotification) ToJson ¶
func (pn *PushNotification) ToJson() (data []byte, err error)