fcm 0.0.6 → 1.0.8
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 +5 -5
- data/.github/workflows/ci.yml +30 -0
- data/.gitignore +1 -1
- data/Gemfile +1 -0
- data/README.md +95 -22
- data/fcm.gemspec +14 -15
- data/lib/fcm.rb +180 -141
- data/spec/fcm_spec.rb +179 -110
- metadata +33 -20
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 16615f79f5432e2a352dc3c26e42d48efed7727a86f04f2b9d2bf93cca47aae6
|
|
4
|
+
data.tar.gz: d2fe30204d7ef51288014fbcc2df5f211ea8d8b4dbbc28cb9af0d9fadc54d6c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06c32340bae1ab25e1d66c06d63fa5d7276214604902218a1a9f5cf06774a60a08ab4bc700616f63ed5563a8b106227ef073168fcbfa29798348fadec2480767
|
|
7
|
+
data.tar.gz: ffa28e382feba7728e496318ea546237c9c5070ccc175d71a2dc83e9adf0a58efa932336a729549599978b6a2406ec01e80bd060997f779631d3a53122660b59
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- '*'
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
tests:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
ruby: ['2.7', '3.0', '3.1']
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@master
|
|
20
|
+
|
|
21
|
+
- name: Set up Ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
|
25
|
+
bundler: default
|
|
26
|
+
bundler-cache: true
|
|
27
|
+
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: |
|
|
30
|
+
bundle exec rspec
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Firebase Cloud Messaging (FCM) for Android and iOS
|
|
2
2
|
|
|
3
|
-
[](http://badge.fury.io/rb/fcm) [](http://badge.fury.io/rb/fcm) [](https://github.com/decision-labs/fcm/actions)
|
|
4
4
|
|
|
5
5
|
The FCM gem lets your ruby backend send notifications to Android and iOS devices via [
|
|
6
6
|
Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/).
|
|
@@ -19,15 +19,56 @@ gem 'fcm'
|
|
|
19
19
|
|
|
20
20
|
For Android you will need a device running 2.3 (or newer) that also have the Google Play Store app installed, or an emulator running Android 2.3 with Google APIs. iOS devices are also supported.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- `2.0.0`
|
|
25
|
-
- `2.1.9`
|
|
26
|
-
- `2.2.5`
|
|
27
|
-
- `2.3.1`
|
|
22
|
+
A version of supported Ruby, currently:
|
|
23
|
+
`ruby >= 2.4`
|
|
28
24
|
|
|
29
25
|
## Usage
|
|
30
26
|
|
|
27
|
+
## HTTP v1 API
|
|
28
|
+
|
|
29
|
+
To migrate to HTTP v1 see: https://firebase.google.com/docs/cloud-messaging/migrate-v1
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
fcm = FCM.new(
|
|
33
|
+
API_TOKEN,
|
|
34
|
+
GOOGLE_APPLICATION_CREDENTIALS_PATH,
|
|
35
|
+
FIREBASE_PROJECT_ID
|
|
36
|
+
)
|
|
37
|
+
message = {
|
|
38
|
+
'topic': "89023", # OR token if you want to send to a specific device
|
|
39
|
+
# 'token': "000iddqd",
|
|
40
|
+
'data': {
|
|
41
|
+
payload: {
|
|
42
|
+
data: {
|
|
43
|
+
id: 1
|
|
44
|
+
}
|
|
45
|
+
}.to_json
|
|
46
|
+
},
|
|
47
|
+
'notification': {
|
|
48
|
+
title: notification.title_th,
|
|
49
|
+
body: notification.body_th,
|
|
50
|
+
},
|
|
51
|
+
'android': {},
|
|
52
|
+
'apns': {
|
|
53
|
+
payload: {
|
|
54
|
+
aps: {
|
|
55
|
+
sound: "default",
|
|
56
|
+
category: "#{Time.zone.now.to_i}"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
'fcm_options': {
|
|
61
|
+
analytics_label: 'Label'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fcm.send_v1(message)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## HTTP Legacy Version
|
|
69
|
+
|
|
70
|
+
To migrate to HTTP v1 see: https://firebase.google.com/docs/cloud-messaging/migrate-v1
|
|
71
|
+
|
|
31
72
|
For your server to send a message to one or more devices, you must first initialise a new `FCM` class with your Firebase Cloud Messaging server key, and then call the `send` method on this and give it 1 or more (up to 1000) registration tokens as an array of strings. You can also optionally send further [HTTP message parameters](https://firebase.google.com/docs/cloud-messaging/http-server-ref) like `data` or `time_to_live` etc. as a hash via the second optional argument to `send`.
|
|
32
73
|
|
|
33
74
|
Example sending notifications:
|
|
@@ -36,19 +77,14 @@ Example sending notifications:
|
|
|
36
77
|
require 'fcm'
|
|
37
78
|
|
|
38
79
|
fcm = FCM.new("my_server_key")
|
|
39
|
-
# you can set option parameters in here
|
|
40
|
-
# - all options are pass to HTTParty method arguments
|
|
41
|
-
# - ref: https://github.com/jnunemaker/httparty/blob/master/lib/httparty.rb#L29-L60
|
|
42
|
-
# fcm = FCM.new("my_server_key", timeout: 3)
|
|
43
80
|
|
|
44
81
|
registration_ids= ["12", "13"] # an array of one or more client registration tokens
|
|
45
82
|
|
|
46
|
-
# See https://
|
|
83
|
+
# See https://firebase.google.com/docs/cloud-messaging/http-server-ref for all available options.
|
|
47
84
|
options = { "notification": {
|
|
48
85
|
"title": "Portugal vs. Denmark",
|
|
49
|
-
"
|
|
50
|
-
}
|
|
51
|
-
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
|
|
86
|
+
"body": "5 to 1"
|
|
87
|
+
}
|
|
52
88
|
}
|
|
53
89
|
response = fcm.send(registration_ids, options)
|
|
54
90
|
```
|
|
@@ -104,14 +140,14 @@ FCM [topic messaging](https://firebase.google.com/docs/cloud-messaging/topic-mes
|
|
|
104
140
|
|
|
105
141
|
```ruby
|
|
106
142
|
response = fcm.send_with_notification_key("/topics/yourTopic",
|
|
107
|
-
|
|
143
|
+
notification: {body: "This is a FCM Topic Message!"})
|
|
108
144
|
```
|
|
109
145
|
|
|
110
146
|
Or you can use the helper:
|
|
111
147
|
|
|
112
148
|
```ruby
|
|
113
149
|
response = fcm.send_to_topic("yourTopic",
|
|
114
|
-
|
|
150
|
+
notification: {body: "This is a FCM Topic Message!"})
|
|
115
151
|
```
|
|
116
152
|
|
|
117
153
|
### Sending to Multiple Topics
|
|
@@ -140,8 +176,8 @@ The `send_to_topic_condition` method within this library allows you to specicy a
|
|
|
140
176
|
```ruby
|
|
141
177
|
response = fcm.send_to_topic_condition(
|
|
142
178
|
"'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)",
|
|
143
|
-
|
|
144
|
-
|
|
179
|
+
notification: {
|
|
180
|
+
body: "This is an FCM Topic Message sent to a condition!"
|
|
145
181
|
}
|
|
146
182
|
)
|
|
147
183
|
```
|
|
@@ -174,11 +210,41 @@ The guide to set up an iOS app to get notifications is here: [Setting up a FCM C
|
|
|
174
210
|
|
|
175
211
|
## ChangeLog
|
|
176
212
|
|
|
213
|
+
### 1.0.8
|
|
214
|
+
- caches calls to `Google::Auth::ServiceAccountCredentials` #103
|
|
215
|
+
- Allow `faraday` versions from 1 up to 2 #101
|
|
216
|
+
|
|
217
|
+
### 1.0.7
|
|
218
|
+
|
|
219
|
+
- Fix passing `DEFAULT_TIMEOUT` to `faraday` [#96](https://github.com/decision-labs/fcm/pull/96)
|
|
220
|
+
- Fix issue with `get_instance_id_info` option params [#98](https://github.com/decision-labs/fcm/pull/98)
|
|
221
|
+
- Accept any IO object for credentials [#95](https://github.com/decision-labs/fcm/pull/94)
|
|
222
|
+
|
|
223
|
+
Huge thanks to @excid3 @jsparling @jensljungblad
|
|
224
|
+
|
|
225
|
+
### 1.0.3
|
|
226
|
+
|
|
227
|
+
- Fix overly strict faraday dependency
|
|
228
|
+
|
|
229
|
+
### 1.0.2
|
|
230
|
+
|
|
231
|
+
- Bug fix: retrieve notification key" params: https://github.com/spacialdb/fcm/commit/b328a75c11d779a06d0ceda83527e26aa0495774
|
|
232
|
+
|
|
233
|
+
### 1.0.0
|
|
234
|
+
|
|
235
|
+
- Bumped supported ruby to `>= 2.4`
|
|
236
|
+
- Fix deprecation warnings from `faraday` by changing dependency version to `faraday 1.0.0`
|
|
237
|
+
|
|
238
|
+
### 0.0.7
|
|
239
|
+
|
|
240
|
+
- replace `httparty` with `faraday`
|
|
241
|
+
|
|
177
242
|
### 0.0.2
|
|
178
243
|
|
|
179
244
|
- Fixed group messaging url.
|
|
180
245
|
- Added API to `recover_notification_key`.
|
|
181
246
|
|
|
247
|
+
|
|
182
248
|
### 0.0.1
|
|
183
249
|
|
|
184
250
|
- Initial version.
|
|
@@ -191,8 +257,15 @@ The guide to set up an iOS app to get notifications is here: [Setting up a FCM C
|
|
|
191
257
|
|
|
192
258
|
- [Contributors](https://github.com/spacialdb/fcm/contributors)
|
|
193
259
|
|
|
194
|
-
##
|
|
260
|
+
## Cutting a release
|
|
195
261
|
|
|
196
|
-
|
|
262
|
+
Update version in `fcm.gemspec` with `VERSION` and update `README.md` `## ChangeLog` section.
|
|
197
263
|
|
|
198
|
-
|
|
264
|
+
```bash
|
|
265
|
+
# set the version
|
|
266
|
+
# VERSION="1.0.7"
|
|
267
|
+
gem build fcm.gemspec
|
|
268
|
+
git tag -a v${VERSION} -m "Releasing version v${VERSION}"
|
|
269
|
+
git push origin --tags
|
|
270
|
+
gem push fcm-${VERSION}.gem
|
|
271
|
+
```
|
data/fcm.gemspec
CHANGED
|
@@ -2,24 +2,23 @@
|
|
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
|
-
s.name
|
|
6
|
-
s.version
|
|
7
|
-
s.platform
|
|
8
|
-
s.authors
|
|
9
|
-
s.email
|
|
10
|
-
s.homepage
|
|
11
|
-
s.summary
|
|
5
|
+
s.name = "fcm"
|
|
6
|
+
s.version = "1.0.8"
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.authors = ["Kashif Rasul", "Shoaib Burq"]
|
|
9
|
+
s.email = ["kashif@decision-labs.com", "shoaib@decision-labs.com"]
|
|
10
|
+
s.homepage = "https://github.com/decision-labs/fcm"
|
|
11
|
+
s.summary = %q{Reliably deliver messages and notifications via FCM}
|
|
12
12
|
s.description = %q{fcm provides ruby bindings to Firebase Cloud Messaging (FCM) a cross-platform messaging solution that lets you reliably deliver messages and notifications at no cost to Android, iOS or Web browsers.}
|
|
13
|
-
s.license
|
|
13
|
+
s.license = "MIT"
|
|
14
14
|
|
|
15
|
-
s.required_ruby_version
|
|
15
|
+
s.required_ruby_version = ">= 2.4.0"
|
|
16
16
|
|
|
17
|
-
s.
|
|
18
|
-
|
|
19
|
-
s.
|
|
20
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
21
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
|
+
s.files = `git ls-files`.split("\n")
|
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
22
20
|
s.require_paths = ["lib"]
|
|
23
21
|
|
|
24
|
-
s.add_runtime_dependency(
|
|
22
|
+
s.add_runtime_dependency("faraday", ">= 1.0.0", "< 3.0")
|
|
23
|
+
s.add_runtime_dependency("googleauth", "~> 1")
|
|
25
24
|
end
|