timehop / apns

A Go package to interface with the Apple Push Notification Service
https://godoc.org/github.com/timehop/apns
MIT License
185 stars 47 forks source link

Related projects #53

Open nathany opened 9 years ago

nathany commented 9 years ago

For a little inspiration, I'm taking a look at other Go projects for APNS, starting with the one @finkel mentioned in #47 and then the one @themartorana mentioned (#38). @willfaught mentioned anachronistic in https://github.com/timehop/apns/pull/26#issuecomment-77654602.

apns by Pranav Raja @pranavraja https://github.com/pranavraja/apns

SendOne, MakeNotification, and ReadInvalid make for a nice lower-level API that other things can be built on. I'm not sure how I feel about the queue. If I was fanning-out the same/similar message to a number of devices or using it as a mechanism for batch & send, maybe it could work, but managing multiple queues at once (requeuing on errors while sending more messages) could become cumbersome for the client.

go-libapns by Karl Kirch @joekarl https://github.com/joekarl/go-libapns

finkel commented 9 years ago

Great idea. The other library you might want to check out (the one I'm actually using now) is https://github.com/virushuo/Go-Apns

pranavraja commented 9 years ago

Thanks for the mention! My library is a few years old, but in case it helps, the main goals were:

I have a SendAll method which does resend messages internally, but in production we were unsure what the right tradeoffs would be so we ended up using the lower-level methods, logging all the failures/resends on the server and adjusting the batching later on to suit our traffic. Benchmarking this was difficult, as you can imagine, so i'm still not sure whether this made much difference - all I remember was that the throughput was 2x compared to my earlier attempt in Ruby =]

joekarl commented 9 years ago

Figure I'll chime in as well. As for mine I was specifically going for speed and correctness on error cases. Most libraries try to resend notifications in error situations which muddies up the error handling in certain cases. I just avoided all of that and just supply the needed information for the user to do what they need to do. This was a better situation than the Java-apns library I had worked on before where there were serious questions about whether error cases were handled correctly. To determine correctness in go-libapns there's actually some pretty decent tests covering the various failure methods from socket level to apple return codes.

Overall though I don't really know that anyone is using it heavily (haven't even been using it myself) but it should be fairly solid at this point. (There was a pretty egregious bug where in connection close all sent pns would say they couldn't be sent but that's been fixed).

arashpayan commented 9 years ago

My turn. :smile: The library is still being used in production on a service, but I don't think it gets massive amounts of traffic, so I can't speak to it's performance characteristics. Interesting point about it storing the recent notifications in a slice vs. a list. I'll need to revisit that the next time I use the code in a project.

I'd also want to improve the error handling. Currently, it only reports invalidToken errors back to the library user (https://github.com/arashpayan/apns/blob/40c200c63099bf022d02db2bc6ff7768953cf7f2/apns.go#L236) but I'd like to improve that so it returns all errors to the library user's callback.

siong1987 commented 9 years ago

I created mine just because there wasn't a good one that I could actually use that worked on Google App Engine. I am no longer using it tho, i wouldn't recommend anyone using it :)

nathany commented 9 years ago

Wow. Thanks everyone. :smiley:

pkar commented 9 years ago

Oh neat, a github mention. I can add that the hermes code is sending out ~20m notifications per day off of a Redis queue. Half for apns for probably a few hundred apps. The final error/retry handling was intentionally left out because it's tied to legacy infrastructure and would have made it a bigger mess

Mistobaan commented 9 years ago

Thank you for the mention. That was my first go project and probably is not the best APNS code out there. Came from the need of having that service when AWS did not provide APNS integration.

joelchen commented 9 years ago

There is also https://github.com/mentionapp/apns.go as mentioned in https://github.com/timehop/apns/issues/50.

nathany commented 8 years ago

Since Apple dropped a new HTTP/2 API #57, I've been working on a new library that requires Go 1.6. https://github.com/RobotsAndPencils/buford

I've used some of the ideas I saw in other libraries while designing the API. Hope you like it, but if not, this is a good time to help tweak it.