All Projects → yuki24 → andpush

yuki24 / andpush

Licence: MIT license
Android Push Notification in Ruby: The fastest client for FCM (Firebase Cloud Messaging)

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to andpush

Node Gcm
A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
Stars: ✭ 1,286 (+1449.4%)
Mutual labels:  notifications, push-notifications, gcm, firebase-cloud-messaging
Easynotifylibproject
Send firebase notifications to your users very easily: A new Android Lib
Stars: ✭ 31 (-62.65%)
Mutual labels:  notifications, push-notifications, fcm, push
Notificationpusher
Standalone PHP library for easy devices notifications push.
Stars: ✭ 1,143 (+1277.11%)
Mutual labels:  notifications, push-notifications, gcm, push
fcmpush
Firebase Cloud Messaging API wrapper for Ruby, suppot HTTP v1 API including access_token auto refresh feature.
Stars: ✭ 44 (-46.99%)
Mutual labels:  push-notifications, fcm, firebase-cloud-messaging, push
Electron Push Receiver
A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).
Stars: ✭ 158 (+90.36%)
Mutual labels:  notifications, push-notifications, fcm, firebase-cloud-messaging
MongoosePush
MongoosePush is a simple Elixir RESTful service allowing to send push notification via FCM and/or APNS.
Stars: ✭ 101 (+21.69%)
Mutual labels:  notifications, gcm, fcm, push
Push Receiver
A library to subscribe to GCM/FCM and receive notifications within a node process.
Stars: ✭ 125 (+50.6%)
Mutual labels:  notifications, push-notifications, fcm, firebase-cloud-messaging
Applozic Android Sdk
Android Real Time Chat & Messaging SDK
Stars: ✭ 611 (+636.14%)
Mutual labels:  notifications, gcm, fcm, firebase-cloud-messaging
Push.js
The world's most versatile desktop notifications framework 🌎
Stars: ✭ 8,536 (+10184.34%)
Mutual labels:  notifications, push-notifications, push
React Native Onesignal
React Native Library for OneSignal Push Notifications Service
Stars: ✭ 1,270 (+1430.12%)
Mutual labels:  notifications, push-notifications, push
Onepush
消息推送用OnePush,就够了!
Stars: ✭ 1,401 (+1587.95%)
Mutual labels:  notifications, push-notifications, push
fcm
Golang client library for Firebase Cloud Messaging.
Stars: ✭ 22 (-73.49%)
Mutual labels:  push-notifications, fcm, firebase-cloud-messaging
Net Core Push Notifications
Lightweight .NET Core Push Notifications for Android and iOS
Stars: ✭ 105 (+26.51%)
Mutual labels:  notifications, push-notifications, fcm
ejabberd mod gcm
Google Cloud Messaging API for Ejabberd (PUSH Messages)
Stars: ✭ 27 (-67.47%)
Mutual labels:  push-notifications, gcm, push
Onesignal Gradle Plugin
Use with OneSignal-Android-SDK to help integrate it into your Android Studio or Gradle project. https://onesignal.com
Stars: ✭ 49 (-40.96%)
Mutual labels:  notifications, gcm, fcm
Push Fcm Plugin
Official Firebase Cloud Messaging plugin for Push.js v1.0 🔥
Stars: ✭ 37 (-55.42%)
Mutual labels:  notifications, fcm, push
epns
📱 Erlang Push Notifications. APNS(Apple Push Notifications) and FCM(Firebase Cloud Messaging) Push Notifications
Stars: ✭ 13 (-84.34%)
Mutual labels:  gcm, fcm, push
Socket.io Push
整合了小米,华为,友盟,谷歌,苹果推送的统一解决方案
Stars: ✭ 605 (+628.92%)
Mutual labels:  notifications, push-notifications, push
mobile-messaging-sdk-ios
Mobile Messaging SDK for iOS
Stars: ✭ 45 (-45.78%)
Mutual labels:  notifications, push-notifications, push
Rpush
The push notification service for Ruby.
Stars: ✭ 1,886 (+2172.29%)
Mutual labels:  notifications, fcm, firebase-cloud-messaging

Andpush Build Status

Andpush is an HTTP client for FCM (Firebase Cloud Messaging). It implements the Firebase Cloud Messaging HTTP Protocol.

The andpush gem performs about 3.7x faster than the fcm gem in a single-threaded environment.

If you are thinking to send push notifications from Rails, consider using the pushing gem, a push notification framework that does not hurt.

Installation

Add this line to your application's Gemfile:

gem 'andpush'

Or install it yourself as:

$ gem install andpush

Usage

You'll need your application's server key, whose value is available in the Cloud Messaging tab of the Firebase console Settings pane.

require 'andpush'

server_key   = "..." # Your server key
device_token = "..." # The device token of the device you'd like to push a message to

client  = Andpush.new(server_key, pool_size: 25)
payload = {
  to: device_token,
  notification: {
    title: "Update",
    body: "Your weekly summary is ready"
  },
  data: { extra: "data" }
}

response = client.push(payload)

headers = response.headers
headers['Retry-After'] # => returns 'Retry-After'

json = response.json
json[:canonical_ids] # => 0
json[:failure]       # => 0
json[:multicast_id]  # => 8478364278516813477

result = json[:results].first
result[:message_id]      # => "0:1489498959348701%3b8aef473b8aef47"
result[:error]           # => nil, "InvalidRegistration" or something else
result[:registration_id] # => nil

Topic Messaging:

topic   = "/topics/foo-bar"
payload = {
  to: topic,
  data: {
    message: "This is a Firebase Cloud Messaging Topic Message!",
  }
}

response = client.push(payload) # => sends a message to the topic

Using HTTP/2 (Experimental)

The current GitHub master branch ships with experimental support for HTTP/2. It takes advantage of the fantastic library, libcurl. In order to use it, replace Andpush.new(...) with Andpush.http2(...):

+# Do not forget to add the curb gem to your Gemfile
+require 'curb'

-client = Andpush.new(server_key, pool_size: 25)
+client = Andpush.http2(server_key) # no need to specify the `pool_size' as HTTP/2 maintains a single connection

Prerequisites

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:

Curl version

If you wish to use the HTTP/2 client in heroku, make sure you are using the 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.

If 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.)

Performance

The andpush gem uses HTTP persistent connections to improve performance. This is done by the net-http-persistent gem. A simple benchmark shows that the andpush gem performs at least 3x faster than the fcm gem:

$ ruby bench.rb
Warming up --------------------------------------
             andpush     2.000  i/100ms
                 fcm     1.000  i/100ms
Calculating -------------------------------------
             andpush     28.009  (± 7.1%) i/s -    140.000  in   5.019399s
                 fcm      7.452  (±13.4%) i/s -     37.000  in   5.023139s

Comparison:
             andpush:       28.0 i/s
                 fcm:        7.5 i/s - 3.76x  slower

Contributing

Bug 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 code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].