frm_mercury 0.1.0 → 0.1.5
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +20 -0
- data/README.md +13 -1
- data/frm_mercury.gemspec +1 -1
- data/lib/frm_mercury/Configuration.rb +14 -0
- data/lib/frm_mercury/sender.rb +35 -0
- data/lib/frm_mercury/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4cd67eb1dc3464cdd916c8d79a214cde79c1d98c2c0065deb785bdd53833f2d
|
4
|
+
data.tar.gz: c38dd5d142f24d81ae66440aa3b9074369086b60a622568434f380fc9883ad99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d35582525b64c1d0f38544dff8d3cb2fd6467c22260e17d934bff1fa8231b6fcade022b2b2c517ba94e2feecd42753d4c895882e1bae227e7539a30528cbb9d3
|
7
|
+
data.tar.gz: 79e644901ab394adbaa009a26c3fd5a2562501400b130ed17cfe50832cd4a9868d52bfc1c4414c844a68bf79725ad436a2a4291e116686213d1384b356b47f73
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
data/README.md
CHANGED
@@ -22,7 +22,19 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
First create an frm_mercury.rb in yours config/initializers
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'frm_mercury'
|
29
|
+
FrmMercury.configure do |config|
|
30
|
+
config.api_key = "Your Api Key From Firebase console"
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Then to send a message...
|
35
|
+
```ruby
|
36
|
+
FrmMercury::Sender.send("Device FCM token as String or many tokens as Array", "Some title", "Some body message", "sound.mp3 (Leave empty for default)", "Hash in case you want to send extra info (optional)")
|
37
|
+
```
|
26
38
|
|
27
39
|
## Development
|
28
40
|
|
data/frm_mercury.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["DEVPENGUIN"]
|
10
10
|
spec.email = ["simoncorreaocampo@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = "Send Firebase Cloud Push Messages easy and simple for Android and iOS"
|
12
|
+
spec.summary = "Send Firebase Cloud Push Messages easy and simple for Android and iOS."
|
13
13
|
spec.homepage = "https://github.com/simoncorreaocampo/FrmMercury"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module FrmMercury
|
2
|
+
class Sender
|
3
|
+
def self.send(to=nil, title=nil, body=nil, sound=nil, data=nil)
|
4
|
+
config = FrmMercury.configuration
|
5
|
+
|
6
|
+
require 'uri'
|
7
|
+
require 'net/http'
|
8
|
+
require 'net/https'
|
9
|
+
require 'json'
|
10
|
+
|
11
|
+
key = to.kind_of?(Array) ? "registration_ids" : "to"
|
12
|
+
|
13
|
+
|
14
|
+
params = {
|
15
|
+
"#{key}": to,
|
16
|
+
"notification": {
|
17
|
+
"title": title.nil? ? "Testing notification" : title,
|
18
|
+
"body": body.nil? ? "This is a test push notification, liking it?" : body,
|
19
|
+
"mutable_content": true,
|
20
|
+
"sound": sound.nil? ? "enabled" : sound
|
21
|
+
},
|
22
|
+
"data": data
|
23
|
+
}.to_json
|
24
|
+
|
25
|
+
uri = URI.parse("https://fcm.googleapis.com/fcm/send")
|
26
|
+
https = Net::HTTP.new(uri.host,uri.port)
|
27
|
+
https.use_ssl = true
|
28
|
+
req = Net::HTTP::Post.new(uri.path, initheader = {"Content-Type" => "application/json", "Authorization" => "key=#{config.get_api_key}"})
|
29
|
+
req.body = params
|
30
|
+
res = https.request(req)
|
31
|
+
puts "Response #{res.code} #{res.message}: #{res.body}"
|
32
|
+
res
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/frm_mercury/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frm_mercury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DEVPENGUIN
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- ".gitignore"
|
49
49
|
- CODE_OF_CONDUCT.md
|
50
50
|
- Gemfile
|
51
|
+
- Gemfile.lock
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
@@ -55,6 +56,8 @@ files:
|
|
55
56
|
- bin/setup
|
56
57
|
- frm_mercury.gemspec
|
57
58
|
- lib/frm_mercury.rb
|
59
|
+
- lib/frm_mercury/Configuration.rb
|
60
|
+
- lib/frm_mercury/sender.rb
|
58
61
|
- lib/frm_mercury/version.rb
|
59
62
|
homepage: https://github.com/simoncorreaocampo/FrmMercury
|
60
63
|
licenses:
|
@@ -79,5 +82,5 @@ rubyforge_project:
|
|
79
82
|
rubygems_version: 2.7.3
|
80
83
|
signing_key:
|
81
84
|
specification_version: 4
|
82
|
-
summary: Send Firebase Cloud Push Messages easy and simple for Android and iOS
|
85
|
+
summary: Send Firebase Cloud Push Messages easy and simple for Android and iOS.
|
83
86
|
test_files: []
|