{"action":"created","issue":{"url":"https://api.github.com/repos/timehop/apns/issues/53","labels_url":"https://api.github.com/repos/timehop/apns/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/timehop/apns/issues/53/comments","events_url":"https://api.github.com/repos/timehop/apns/issues/53/events","html_url":"https://github.com/timehop/apns/issues/53","id":79564542,"number":53,"title":"Related projects","user":{"login":"nathany","id":4566,"avatar_url":"https://avatars.githubusercontent.com/u/4566?v=3","gravatar_id":"","url":"https://api.github.com/users/nathany","html_url":"https://github.com/nathany","followers_url":"https://api.github.com/users/nathany/followers","following_url":"https://api.github.com/users/nathany/following{/other_user}","gists_url":"https://api.github.com/users/nathany/gists{/gist_id}","starred_url":"https://api.github.com/users/nathany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathany/subscriptions","organizations_url":"https://api.github.com/users/nathany/orgs","repos_url":"https://api.github.com/users/nathany/repos","events_url":"https://api.github.com/users/nathany/events{/privacy}","received_events_url":"https://api.github.com/users/nathany/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-22T18:42:25Z","updated_at":"2015-05-24T19:16:59Z","closed_at":null,"body":"For a little inspiration, I'm taking a look at other [Go projects for APNS](http://godoc.org/?q=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.\r\n\r\n#### apns by Pranav Raja @pranavraja https://github.com/pranavraja/apns\r\n* Exposes a queue (a slice) for sending multiple notifications at once. Timehop has an internal circular buffer rather than exposing a queue. Currently neither implementation [batches multiple notifications into a single frame](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW4).\r\n* It uses the synchronous approach of sending a batch, then reading with a timeout. Timehop does the read on a separate goroutine. Based on [Apple's documentation](https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG44) I believe the separate goroutine to be more responsive, though reading with a timeout does make for a nice and simple synchronous API.\r\n* Rather than resend failed messages internally, it reports what was unsent and reslices the queue for resending (less magic).\r\n* There is a timeout parameter for sending. :+1:\r\n* Exposes a lower-level API to read errors from the socket and decode the Apple format. This is an interesting alternative to passing those errors over a channel. Timehop does a blocking read in a goroutine and sends errors over FailedNotifs, but a blocking read in a goroutine could be part of the client code or a high-level API.\r\n* Offers a lower-level interface where you can make a notification before sending it.\r\n* Notification is a separate package. :+1:\r\n* MakeNotification takes a string rather than defining the structs for JSON serialization.\r\n\r\nSendOne, 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. \r\n\r\n#### go-libapns by Karl Kirch @joekarl https://github.com/joekarl/go-libapns\r\n\r\n* Batches push notifications up to 64K (TCP packet size) and flushes every 10ms. This is accomplished with an internal inFlightFrameByteBuffer.\r\n* Doesn't use Nagel #32 in order to have a shorter timeout length (REAMDE includes explanation)\r\n* Provides two functions for creating connections, one takes an existing tcp net.Conn for use on Google App Engine, etc.\r\n* API uses channels (SendChannel) rather than a Send() method (Timehop currently puts a notification into an internal channel). Also uses a runLoop called sendListener.\r\n* When an error occurs, it sends the notification that failed and all the unset notifications over a CloseChannel.\r\n* To clear badges, it was relying on negative numbers (instead of 0), but now uses BadgeNumber from @themartorana. See #38.\r\n* It will clip the alert body if the payload is over Apple's 2K limit.\r\n\r\n#### apns by @anachronistic https://github.com/anachronistic/apns\r\n\r\n* Alert uses an interface that can be either a string or an AlertDictionary. Timehop currently checks if only Alert.Body is set and serializes the JSON in the more efficient way, but the API still requires an Alert struct.\r\n* It has a PayloadString() for serializing the JSON without doing the binary encoding or sending it.\r\n* It connects, writes and waits for a response (with a timeout) all in one step. This may be fine for very low-volume push notifications, but Apple treats [rapid connection and disconnection as a denial-of-service attack](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW6).\r\n* Overrides Badge 0 to -1 (not sure the point, vs just not using omitempty). Not sure if it's possible to leave badge as-is (omitempty)?\r\n* Does a check for MaxPayloadSizeBytes and returns an error. Timehop does not.\r\n* Generates a pseudo-random identifier up to 9999 rather than incrementing a counter or requesting it from the caller.\r\n\r\n#### apns by Arash Payan @arashpayan https://github.com/arashpayan/apns\r\n\r\n* Uses a pseudo-random identifier like anachronistic.\r\n* Uses a slice to store the last 25 notifications (rather than a list). Hm.\r\n* Uses an invalidTokenHandler callback\r\n* Exponential backoff for reconnects.\r\n\r\n#### apns by Ryan Slade @ryanslade https://github.com/ryanslade/apns\r\n* Has a shortcut for pushing a message with just an alert (PushMessage).\r\n* Uses an idChan to generate incrementing identifiers\r\n* Launches a go routine to resend payloads on failure.\r\n* Holds on to a slice of payloads and cleans them up after 5 minutes rather than using a circular list that limits the amount.\r\n\r\n#### apns on App Engine by Siong @siong1987 https://github.com/siong1987/apns\r\n* This uses appengine.Context and appengine/socket.\r\n* It has it's own PEM loader that supports keys with a passphrase.\r\n* Uses the synchronous read after writing method.\r\n* Has a connection pool (10 connections to Apple).\r\n* Uses a pseudo-random identifier like anachronistic.\r\n\r\n#### hermes APNS/GCM by Paul Karadimas @pkar https://github.com/pkar/hermes\r\n\r\n#### Go-APNs by Matthew Price @mattprice https://github.com/mattprice/Go-APNs\r\n\r\n#### apns-go by @Kwik-messenger https://github.com/Kwik-messenger/apns-go\r\n\r\n#### go_apns by @MessageDream https://github.com/MessageDream/go_apns\r\n\r\n#### Go-Apns by @virushuo Ju Huo https://github.com/virushuo/Go-Apns\r\n* The example is interesting in that mutates an existing payload, yet Send takes a pointer to a notification. Hm.\r\n* Overall a similar architecture with a sendLoop and reconnecting. It also uses an errorChan for reporting errors (but of type error) and a concrete NotificationError struct with an OtherError for storing read errors, etc.\r\n\r\n#### APNs by Cornel Damian @corneldamian https://github.com/corneldamian/APNs\r\n\r\n#### APNs by Matt DuVall @mduvall https://github.com/mduvall/go-apns\r\n\r\n#### go-apns by Fabrizio Milo @Mistobaan https://github.com/Mistobaan/go-apns\r\n\r\n#### Apns by @houxiaobei https://github.com/houxiaobei/Apns\r\n"},"comment":{"url":"https://api.github.com/repos/timehop/apns/issues/comments/105053097","html_url":"https://github.com/timehop/apns/issues/53#issuecomment-105053097","issue_url":"https://api.github.com/repos/timehop/apns/issues/53","id":105053097,"user":{"login":"siong1987","id":5866,"avatar_url":"https://avatars.githubusercontent.com/u/5866?v=3","gravatar_id":"","url":"https://api.github.com/users/siong1987","html_url":"https://github.com/siong1987","followers_url":"https://api.github.com/users/siong1987/followers","following_url":"https://api.github.com/users/siong1987/following{/other_user}","gists_url":"https://api.github.com/users/siong1987/gists{/gist_id}","starred_url":"https://api.github.com/users/siong1987/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siong1987/subscriptions","organizations_url":"https://api.github.com/users/siong1987/orgs","repos_url":"https://api.github.com/users/siong1987/repos","events_url":"https://api.github.com/users/siong1987/events{/privacy}","received_events_url":"https://api.github.com/users/siong1987/received_events","type":"User","site_admin":false},"created_at":"2015-05-24T19:16:59Z","updated_at":"2015-05-24T19:16:59Z","body":"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 :)"}}