{"id":20569524,"url":"https://github.com/divs1210/pushy-clj","last_synced_at":"2025-04-14T16:35:19.212Z","repository":{"id":57714151,"uuid":"59660769","full_name":"divs1210/pushy-clj","owner":"divs1210","description":"Send APNs push notifications using the new HTTP/2 protocol from Clojure","archived":false,"fork":false,"pushed_at":"2019-06-27T22:48:40.000Z","size":29,"stargazers_count":27,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T05:13:47.352Z","etag":null,"topics":["apns2","clojure","push-notifications"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/divs1210.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-25T12:19:47.000Z","updated_at":"2023-12-19T02:02:21.000Z","dependencies_parsed_at":"2022-09-26T21:31:14.464Z","dependency_job_id":null,"html_url":"https://github.com/divs1210/pushy-clj","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2Fpushy-clj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2Fpushy-clj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2Fpushy-clj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divs1210%2Fpushy-clj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/divs1210","download_url":"https://codeload.github.com/divs1210/pushy-clj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248917171,"owners_count":21182945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apns2","clojure","push-notifications"],"created_at":"2024-11-16T05:08:34.266Z","updated_at":"2025-04-14T16:35:19.181Z","avatar_url":"https://github.com/divs1210.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pushy-clj\n\nA Clojure library for sending push notifications via APNS to Apple devices\nusing the new HTTP/2 protocol.\n\nIt's a thin wrapper around [Pushy](https://github.com/relayrides/pushy).\n\nMake sure you have one of:\n* [Universal Push Notification Client SSL Certificate](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW11)\n* APNS Auth Key from [Apple member center](https://developer.apple.com/account/)\n\n## Leiningen\n\nThe current stable version is:\n\n`[pushy-clj \"0.4.2\"]`\n\n## Usage\n\n\u003e :wrench: If you are upgrading from versions prior to 0.4.0, note\n\u003e that the API has changed, because of deep changes to the API of the\n\u003e Pushy Java library itself. You will need to change your existing\n\u003e code to conform to the examples below. There is no longer a\n\u003e no-argument version of `make-client`, and you need to provide the\n\u003e `:dev` or `:prod` keyword as a new, first argument. There is also no\n\u003e longer a `connect` function; Pushy takes responsibility for the\n\u003e connection as soon as you create the client, until you call\n\u003e `disconnect`.\n\nFirst, we create a client and connect to the APNs development server:\n\n```clojure\n(require '[pushy-clj.core :refer :all]\n         '[clojure.java.io :as io])\n\n(import 'java.io.File)\n\n;; Old-school certificate-based auth\n(with-open [cert (io/input-stream (File. \"/path/to/cert.p12\"))]\n  (def client (make-client :dev cert \"password\")))\n                    ;; use :prod in production env\n\n;; New token-based auth\n(with-open [key (io/input-stream (File. \"/path/to/key.p8\"))]\n  (def client (make-client :dev key \"team-id\" \"key-id\")))\n\n```\n\nPushy is responsible for opening the connection to the specified\nserver, and reopening it if anything causes it to close.\n\nThen we build a notification following Apple's [guidelines](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1):\n\n```clojure\n(def payload {:aps {:alert \"Hello!\"}})\n\n(def notification (build-push-notification \"device-token\" \n                                           \"topic\" ;; this can be nil\n                                           payload))\n```\n\nNow, we can send the notification:\n\n```clojure\n(def resp-future (send-push-notification client notification)) ;; async operation!\n```\n\nThe notification is sent asynchronously, and `resp-future` is returned immediately.\nThis future can be derefed to get the response as a hashmap.\n\n```clojure\n@resp-future ;; blocking operation\n\n;; =\u003e {:accepted? true\n;;     :rejection-reason nil\n;;     :token-expiration-ts nil}\n```\n\nFinally, we can close the connection using `disconnect`:\n\n```clojure\n(disconnect client) ;; blocking operation\n```\n\n## License\n\nCopyright © 2016 Divyansh Prakash\n\nDistributed under the Eclipse Public License version 1.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivs1210%2Fpushy-clj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivs1210%2Fpushy-clj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivs1210%2Fpushy-clj/lists"}