fcmpush 0.9.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 559e27187a6c96f09ab2f769ade358a3eee9a99880ca17662d5cc2fcec9956c9
4
- data.tar.gz: 1dca034d51e28ff9474d71550d8601ae131762b93d0ca80a014703b234a97045
2
+ SHA1:
3
+ metadata.gz: 327bff9a6b09181d0051f314ba3fc9216c71ffc8
4
+ data.tar.gz: b2e7fcea6ba6f0af379309d6071faca78d20f482
5
5
  SHA512:
6
- metadata.gz: 670206fca4a4e671044acf9ff8629a1260d719c632db385a2f015f34ab1192f1a79fb4dda29131b3e45bb8c8c24aec0790cc56eb33712103b9a944370c2d978f
7
- data.tar.gz: 0c5477c168493bf36031824b4f1ae2db7505c8b9c9b81c146982ffc0481f5a83ab86b0813b5d8b5c2022632c2a24a2fdff6c40190f61345ea025a4b14718facd
6
+ metadata.gz: 828348d829eb7f3e18f351bbc33937ab4b5d7a767376ae27f6e2b46e2b0b38d9fa40d19323157f8ef1453f1f5b04ddda6f8c4bfe7025b6bf537f38452b85ae8c
7
+ data.tar.gz: c2801903d5651c554cb11e076cd3d0c71088f88be0671d2d06f2c6b5f6b9c6aa7b2f4a544cbcc7e90c3ab5bbe0fc0b5bb3f3bc423954a7855ebddd4cf966987f
data/fcmpush.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['miyataka']
9
9
  spec.email = ['voyager.3taka28@gmail.com']
10
10
 
11
- spec.summary = 'Firebase Cloud Messaging API wrapper for ruby, supports HTTP v1.'
11
+ spec.summary = 'Firebase Cloud Messaging API wrapper for ruby, supports HTTP v1. And including access_token Auto Refresh feature!'
12
12
  spec.homepage = 'https://github.com/miyataka/fcmpush'
13
13
  spec.license = 'MIT'
14
14
 
@@ -16,12 +16,14 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata['source_code_uri'] = 'https://github.com/miyataka/fcmpush'
17
17
 
18
18
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ `git ls-files -z`.split("\x0").select { |f| f.match(%r{^(lib/|fcmpush.gemspec)}) }
20
20
  end
21
21
  spec.bindir = 'exe'
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
+ spec.required_ruby_version = '>= 2.3', '< 2.8'
26
+
25
27
  spec.add_dependency 'googleauth', '>= 0.9.0'
26
28
  spec.add_dependency 'net-http-persistent', '>= 3.1.0'
27
29
 
@@ -1,3 +1,4 @@
1
+ require 'delegate' if RUBY_VERSION >= '2.7'
1
2
  require 'json'
2
3
 
3
4
  module Fcmpush
@@ -1,3 +1,3 @@
1
1
  module Fcmpush
2
- VERSION = '0.9.2'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fcmpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miyataka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-14 00:00:00.000000000 Z
11
+ date: 2019-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: googleauth
@@ -87,16 +87,6 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".gitignore"
91
- - ".rspec"
92
- - ".rubocop.yml"
93
- - ".travis.yml"
94
- - Gemfile
95
- - LICENSE.txt
96
- - README.md
97
- - Rakefile
98
- - bin/console
99
- - bin/setup
100
90
  - fcmpush.gemspec
101
91
  - lib/fcmpush.rb
102
92
  - lib/fcmpush/client.rb
@@ -118,15 +108,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
108
  requirements:
119
109
  - - ">="
120
110
  - !ruby/object:Gem::Version
121
- version: '0'
111
+ version: '2.3'
112
+ - - "<"
113
+ - !ruby/object:Gem::Version
114
+ version: '2.8'
122
115
  required_rubygems_version: !ruby/object:Gem::Requirement
123
116
  requirements:
124
117
  - - ">="
125
118
  - !ruby/object:Gem::Version
126
119
  version: '0'
127
120
  requirements: []
128
- rubygems_version: 3.0.3
121
+ rubyforge_project:
122
+ rubygems_version: 2.6.14.4
129
123
  signing_key:
130
124
  specification_version: 4
131
- summary: Firebase Cloud Messaging API wrapper for ruby, supports HTTP v1.
125
+ summary: Firebase Cloud Messaging API wrapper for ruby, supports HTTP v1. And including
126
+ access_token Auto Refresh feature!
132
127
  test_files: []
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- /vendor/bundle
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,11 +0,0 @@
1
- Style/FrozenStringLiteralComment:
2
- Enabled: false
3
-
4
- Metrics/LineLength:
5
- Enabled: false
6
-
7
- Style/Documentation:
8
- Enabled: false
9
-
10
- Layout/IndentationConsistency:
11
- EnforcedStyle: indented_internal_methods
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- script: bundle exec rspec
5
- rvm:
6
- - 2.3.8
7
- - 2.4.9
8
- - 2.5.7
9
- - 2.6.5
10
- before_install: gem install bundler -v 2.0.2
11
- notifications:
12
- slack:
13
- secure: Uckm/iIr1N6dvkzJeGes8yARAQSHLFGWjAw7CsNGiU5KERf0a/WWo+8OoWAqBtgcnqVDdBcNm0aUax+5JbfyLg0q8YW1wtYuAE2Gqocvs5TPt8XwyEQv6sYyN1mqrcJWl4FO22DCxF+Oetju1wEjpjSVYs6uzDrj7U6HzuJON/yd+lUjJWOD1OOaRJUYjI9uU7x7RRscECGU8p0ffjeiGOkM2EuJ/osA/CeDlDd93hlUpseZqxceQGdsSZHscbqV0eWVDexoPtUOIK08VFgCk3FIA4vfO8XDaBibSiqiTYUPGPQILjMhGKmB/dmz2LyxdWGdCBOjH1CnD1LXNq9yPhquDXm/2u4cVWIV7bgOHDZ6ylRz0u+AUWVMI/VJOd27YOkZCGgqbb12Y7sBh0m9KalU/fqfIafOvt24j5o2abjJCKHoTUgdESpbLYqnZvK00uRjjOp0H0yQnXicaFE4lByAGbxmpxWZ3fs1OZkppYOl8dF9AQWB6Uty4KraTpUB6fGHoE7/IPeUNsENXWPUqITsRDPFjCTWED/YvKfUi+xTA+K1vJZympsPevT6xcL82TXGDtdHA4U52MLiAuizXP/+R3XhO2PzBSyLbEMus2iJYwXsIac157uhcDrECQfIkm9DMtSHKP83ABf/Flj73NKayWYP0OsigBdUYVgs5aQ=
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in fcmpush.gemspec
4
- gemspec
5
-
6
- gem 'activesupport', '< 6.0'
7
- gem 'pry-byebug'
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 Takayuki Miyahara
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,125 +0,0 @@
1
- # Fcmpush [![Build Status](https://travis-ci.org/miyataka/fcmpush.svg?branch=master)](https://travis-ci.org/miyataka/fcmpush)
2
-
3
- Fcmpush is an Firebase Cloud Messaging(FCM) Client. It implements [FCM HTTP v1 API](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages), including **Auto Refresh** access_token feature!!
4
- This gem supports HTTP v1 API only, **NOT supported [legacy HTTP protocol](https://firebase.google.com/docs/cloud-messaging/http-server-ref)**.
5
-
6
- fcmpush is highly inspired by [andpush gem](https://github.com/yuki24/andpush).
7
-
8
- ## Installation
9
-
10
- Add this line to your application's Gemfile:
11
-
12
- ```ruby
13
- gem 'fcmpush'
14
- ```
15
-
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install fcmpush
23
-
24
- ## Usage
25
-
26
- on Rails, config/initializers/fcmpush.rb
27
- ```ruby
28
- Fcmpush.configure do |config|
29
- ## for message push
30
- # firebase web console => project settings => service account => firebase admin sdk => generate new private key
31
- config.json_key_io = "#{Rails.root}/path/to/service_account_credentials.json"
32
-
33
- # Or set environment variables
34
- # ENV['GOOGLE_ACCOUNT_TYPE'] = 'service_account'
35
- # ENV['GOOGLE_CLIENT_ID'] = '000000000000000000000'
36
- # ENV['GOOGLE_CLIENT_EMAIL'] = 'xxxx@xxxx.iam.gserviceaccount.com'
37
- # ENV['GOOGLE_PRIVATE_KEY'] = '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n\'
38
-
39
- ## for topic subscribe/unsubscribe because they use regacy auth
40
- # firebase web console => project settings => cloud messaging => Project credentials => Server key
41
- config.server_key = 'your firebase server key'
42
- # Or set environment variables
43
- # ENV['FCM_SERVER_KEY'] = 'your firebase server key'
44
- end
45
- ```
46
-
47
- for more detail. see [here](https://github.com/googleapis/google-auth-library-ruby#example-service-account).
48
-
49
- ### push message
50
- ```ruby
51
- require 'fcmpush'
52
-
53
- project_id = "..." # Your project_id
54
- device_token = "..." # The device token of the device you'd like to push a message to
55
-
56
- client = Fcmpush.new(project_id)
57
- payload = { # ref. https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
58
- message: {
59
- token: device_token,
60
- notification: {
61
- title: "this is title",
62
- body: "this is message body"
63
- }
64
- }
65
- }
66
-
67
- response = client.push(payload)
68
-
69
- json = response.json
70
- json[:name] # => "projects/[your_project_id]/messages/0:1571037134532751%31bd1c9631bd1c96"
71
- ```
72
-
73
- ### topic subscribe/unsubscribe
74
- ```ruby
75
- require 'fcmpush'
76
-
77
- project_id = "..." # Your project_id
78
- topic = "your_topic_name"
79
- device_tokens = ["device_tokenA", "device_tokenB", ...] # The device tokens of the device you'd like to subscribe
80
-
81
- client = Fcmpush.new(project_id)
82
-
83
- response = client.subscribe(topic, device_tokens)
84
- # response = client.unsubscribe(topic, device_tokens)
85
-
86
- json = response.json
87
- json[:results] # => [{}, {"error":"NOT_FOUND"}, ...] ref. https://developers.google.com/instance-id/reference/server#example_result_3
88
- ```
89
-
90
- ## Performance
91
- - fcmpush's performance is good. (at least not so bad.)
92
- - [andpush](https://github.com/yuki24/andpush) is the fastest, but it uses legacy HTTP API.
93
- - fcmpush is fastest in gems using V1 HTTP API(fcmpush, [google-api-fcm](https://github.com/oniksfly/google-api-fcm), [firebase_cloud_messenger](https://github.com/vincedevendra/firebase_cloud_messenger)).
94
- - benchmark detail is [here](https://gist.github.com/miyataka/8787021724ee7dc5cecea88913f3af8c).
95
- ```
96
- Warming up --------------------------------------
97
- andpush 1.000 i/100ms
98
- fcm 1.000 i/100ms
99
- fcmpush 1.000 i/100ms
100
- google-api-fcm 1.000 i/100ms
101
- firebase_cloud_messenger
102
- 1.000 i/100ms
103
- Calculating -------------------------------------
104
- andpush 13.161 (±15.2%) i/s - 63.000 in 5.010981s
105
- fcm 6.177 (±16.2%) i/s - 30.000 in 5.066638s
106
- fcmpush 7.237 (±13.8%) i/s - 36.000 in 5.098668s
107
- google-api-fcm 6.889 (±14.5%) i/s - 33.000 in 5.031508s
108
- firebase_cloud_messenger
109
- 2.766 (± 0.0%) i/s - 14.000 in 5.079574s
110
-
111
- Comparison:
112
- andpush: 13.2 i/s
113
- fcmpush: 7.2 i/s - 1.82x slower
114
- google-api-fcm: 6.9 i/s - 1.91x slower
115
- fcm: 6.2 i/s - 2.13x slower
116
- firebase_cloud_messenger: 2.8 i/s - 4.76x slower
117
- ```
118
-
119
- ## Contributing
120
-
121
- Bug reports and pull requests are welcome on GitHub at https://github.com/miyataka/fcmpush.
122
-
123
- ## License
124
-
125
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "fcmpush"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here