One notification object can be sent to multiple devices while only one copy of the notification is kept in memory.
* You should use the new `pushNotification` method to benefit from this. Instead of setting `Notification#device` you instead need to pass an array of device tokens to `pushNotification` as the second parameter.
* The notification object returned by errors has changed structure.
* There is now code to support multiple connections sending notifications but this isn't fully enabled yet, it may work in your environment but hasn't been tested.
Backwards compatibility is maintained with the previous callback system by attaching them to events. Passing callback functions is deprecated and this will eventually be removed.
I am extremely grateful for the work performed by the people listed and I wish to extend my thanks to them. However, as they have not directly contributed large quantities of code I am apprehensive to use the term Contributors. I hope this decision does not upset anyone.
Two new options:
autoAdjustCache. If Apple returns an error for a notification which has been lost due to the cache being too small, when this is set to true the module will make a simple estimate of how many notifications have been lost and increase the cacheLength by twice that amount.
connectionTimeout. Set the socket connection timeout value, if set (value >0 in milliseconds) then after a period of inactivity the socket will automatically disconnect. Note: if further notifications are sent the socket will be re-established automatically.
*********
When a connection is created it is now possible to add eventListeners to monitor the modules progress.
Events (arguments):
- error (error): emitted when an error occurs during initialisation of the module, usually due to a problem with the keys and certificates.
- transmitted (notification): emitted when a notification has been sent to Apple - not a guarantee that it has been accepted by Apple, an error relating to it make occur later on. A notification may also be sent several times if an earlier notification caused an error requiring retransmission.
- timeout: emitted when the connectionTimeout option has been specified and no activity has occurred on a socket for a specified duration. The socket will be closed immediately after this event.
- connected: emitted when the connection to Apple is successfully established. No action is required as the connection is managed internally.
- disconnected: emitted when the connection to Apple has been closed, this could be for numerous reasons, for example an error has occurred or the connection has timed out. No action is required.
- socketError (error): emitted when the connection socket experiences an error. This is useful for debugging but no action should be necessary.
- transmissionError (error code, notification): emitted when a message has been received from Apple stating that a notification was invalid. If we still have the notification in cache it will be passed as the second argument, otherwise null.
- cacheTooSmall (difference): emitted when Apple returns a notification as invalid but the notification has been expunged from the cache - usually due to high throughput. The parameter estimates how many notifications have been lost.
Trying to attach error handler as soon as possible as it seems to be getting delayed.
Added a stack trace in raiseError though I'm not sure it'll do much
Improved a check when sending notifications if the socket is not available.