{"id":15293295,"url":"https://github.com/yuki24/andpush","last_synced_at":"2025-04-09T21:20:12.500Z","repository":{"id":59150574,"uuid":"85023574","full_name":"yuki24/andpush","owner":"yuki24","description":"Android Push Notification in Ruby: The fastest client for FCM (Firebase Cloud Messaging)","archived":false,"fork":false,"pushed_at":"2018-12-26T18:46:35.000Z","size":145,"stargazers_count":82,"open_issues_count":4,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T19:07:11.114Z","etag":null,"topics":["android","fcm","firebase-cloud-messaging","gcm","google-cloud-messaging","notifications","push","push-notifications","ruby"],"latest_commit_sha":null,"homepage":"https://github.com/yuki24/andpush","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuki24.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-15T03:13:05.000Z","updated_at":"2024-09-28T13:47:55.000Z","dependencies_parsed_at":"2022-09-13T11:00:20.575Z","dependency_job_id":null,"html_url":"https://github.com/yuki24/andpush","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki24%2Fandpush","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki24%2Fandpush/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki24%2Fandpush/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki24%2Fandpush/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuki24","download_url":"https://codeload.github.com/yuki24/andpush/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248112222,"owners_count":21049617,"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":["android","fcm","firebase-cloud-messaging","gcm","google-cloud-messaging","notifications","push","push-notifications","ruby"],"created_at":"2024-09-30T16:46:07.165Z","updated_at":"2025-04-09T21:20:12.474Z","avatar_url":"https://github.com/yuki24.png","language":"Ruby","readme":"# Andpush [![Build Status](https://travis-ci.org/yuki24/andpush.svg?branch=master)](https://travis-ci.org/yuki24/andpush)\n\nAndpush is an HTTP client for FCM (Firebase Cloud Messaging). It implements [the Firebase Cloud Messaging HTTP Protocol](https://firebase.google.com/docs/cloud-messaging/http-server-ref).\n\nThe `andpush` gem performs **about 3.7x faster** than [the fcm gem](https://github.com/spacialdb/fcm) in a single-threaded environment.\n\n**If you are thinking to send push notifications from Rails, consider using the [pushing gem](https://github.com/yuki24/pushing), a push notification framework that does not hurt.**\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'andpush'\n```\n\nOr install it yourself as:\n\n    $ gem install andpush\n\n## Usage\n\nYou'll need your application's server key, whose value is available in the [Cloud Messaging](https://console.firebase.google.com/project/_/settings/cloudmessaging) tab of the Firebase console Settings pane.\n\n```ruby\nrequire 'andpush'\n\nserver_key   = \"...\" # Your server key\ndevice_token = \"...\" # The device token of the device you'd like to push a message to\n\nclient  = Andpush.new(server_key, pool_size: 25)\npayload = {\n  to: device_token,\n  notification: {\n    title: \"Update\",\n    body: \"Your weekly summary is ready\"\n  },\n  data: { extra: \"data\" }\n}\n\nresponse = client.push(payload)\n\nheaders = response.headers\nheaders['Retry-After'] # =\u003e returns 'Retry-After'\n\njson = response.json\njson[:canonical_ids] # =\u003e 0\njson[:failure]       # =\u003e 0\njson[:multicast_id]  # =\u003e 8478364278516813477\n\nresult = json[:results].first\nresult[:message_id]      # =\u003e \"0:1489498959348701%3b8aef473b8aef47\"\nresult[:error]           # =\u003e nil, \"InvalidRegistration\" or something else\nresult[:registration_id] # =\u003e nil\n```\n\n### Topic Messaging:\n\n```ruby\ntopic   = \"/topics/foo-bar\"\npayload = {\n  to: topic,\n  data: {\n    message: \"This is a Firebase Cloud Messaging Topic Message!\",\n  }\n}\n\nresponse = client.push(payload) # =\u003e sends a message to the topic\n```\n\n## Using HTTP/2 (Experimental)\n\nThe current GitHub master branch ships with experimental support for HTTP/2. It takes advantage of the fantastic library, [libcurl](https://curl.haxx.se/libcurl/). In order to use it, replace `Andpush.new(...)` with `Andpush.http2(...)`:\n\n```diff\n+# Do not forget to add the curb gem to your Gemfile\n+require 'curb'\n\n-client = Andpush.new(server_key, pool_size: 25)\n+client = Andpush.http2(server_key) # no need to specify the `pool_size' as HTTP/2 maintains a single connection\n```\n\n### Prerequisites\n\n * [libcurl](https://curl.haxx.se/download.html) 7.43.0 or later\n * [nghttp2](https://nghttp2.org/blog/) 1.0 or later\n\n**Make sure that your production environment has the compatible versions installed. If you are not sure what version of libcurl you are using, try running `curl --version` and make sure it has `HTTP2` listed in the Features:**\n\n![Curl version](assets/curl-version.png \"Curl version\")\n\n**If you wish to use the HTTP/2 client in heroku, make sure you are using [the `Heroku-18` stack](https://devcenter.heroku.com/articles/heroku-18-stack). Older stacks, such as `Heroku-16` and `Cedar-14` do not ship with a version of libcurl that has support for HTTP/2.**\n\nIf you are using an older version of libcurl that doesn't support HTTP/2, don't worry. It will just fall back to HTTP 1.1 (of course without header compression and multiplexing.)\n\n## Performance\n\nThe andpush gem uses [HTTP persistent connections](https://en.wikipedia.org/wiki/HTTP_persistent_connection) to improve performance. This is done by [the net-http-persistent gem](https://github.com/drbrain/net-http-persistent). [A simple benchmark](https://gist.github.com/yuki24/e0db97e887b8b6eb1932c41b4cea4a99) shows that the andpush gem performs at least 3x faster than the fcm gem:\n\n```sh\n$ ruby bench.rb\nWarming up --------------------------------------\n             andpush     2.000  i/100ms\n                 fcm     1.000  i/100ms\nCalculating -------------------------------------\n             andpush     28.009  (± 7.1%) i/s -    140.000  in   5.019399s\n                 fcm      7.452  (±13.4%) i/s -     37.000  in   5.023139s\n\nComparison:\n             andpush:       28.0 i/s\n                 fcm:        7.5 i/s - 3.76x  slower\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/yuki24/andpush. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuki24%2Fandpush","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuki24%2Fandpush","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuki24%2Fandpush/lists"}