Giter VIP home page Giter VIP logo

go-libapns's People

Contributors

afex avatar ashearer avatar asib avatar blixt avatar joekarl avatar justinrosenthal avatar mikedotexe avatar themartorana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-libapns's Issues

Payload rejected when priority is set

When priority is set, APNS rejects payload and closes connection. Issue is in connection.go line 479 writing priority data length.

binary.Write(c.inFlightItemByteBuffer, binary.BigEndian, uint8(4))

Should be

binary.Write(c.inFlightItemByteBuffer, binary.BigEndian, uint8(1))

thank you

Implement custom logger

Allow passing in a custom *Logger in APNSConfig so logging can be passed to more than just stdout.

Worker

I'm making a beanstlkd worker that listens for HTTP requests to send a notification from an external source.
As it receives these, it adds it as a payload to your package.

I need it to always be running.
I'm looking at your sample code: https://gist.github.com/joekarl/86d9bdb8f9af044710b7

To achieve this, do I just never send a message through the doneWritingChan channel?
Also what do I do if the connection gets closed. How can I automatically open the connection?

Think about moving payload validation outside of the library

Basically because message validation is done behind the channel interface, there's no good way to get back errors if a payload is bad.
Thinking about moving payload validation to an exposed method so that users can pre-validate their messages if they want to.
Will still leave checks in place internally for saneness but will allow preemptive catching of potential errors.

Invalid token size error

Just a suggestion, but I spent a while debugging an error where I was trying to send payloads that would force an Apple error response, and because I'm lazy I was trying to do this by using invalid tokens like "abcd".

What I realised is that, because this is hex-decodable, the library is happy with it, but it causes an non-obvious bug. Given Apple expects tokens to be 32 bytes, sending a message with a token that's any other size will mean all the other fields are out of place. I ended up getting a MISSING_PAYLOAD for both valid and invalid tokens (due to framing - I was sending batches of notifications) and it took me a while to realise what the problem actually was.

So I was wondering whether it would be appropriate to introduce a token length check in bufferPayload() that returns an error if the non-decoded token is anything other than 64 bytes (this way we can avoid wasting time decoding it if it's an invalid length). It should go just before this line (

token, err := hex.DecodeString(idPayloadObj.Payload.Token)
)

(Potential) race condition on close

When Disconnect() is called, all that happens is the in flight buffer gets locked and then the socket is closed. The problem is if this is used in a multithreaded environment and there are any unsent payloads outside of the inflight buffer after Disconnect is called, the inflight buffer will never be flushed and there's a potential to lose whatever payload was being added as the connection was closed.

Probably just need to add an extra conditional here (https://github.com/joekarl/go-libapns/blob/master/connection.go#L299-L309) so that if the connection closed without an apple error, we return the unsent payload(s).

Allow custom socket

Currently the function for creating an APNSConnection with a custom socket is private (used by the test). This functionality would be useful publicly for sandboxed environments where a different net.Conn implementation must be used (e.g., App Engine's socket module).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.