jera_push 2.1.0 → 2.1.2
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/lib/generators/active_record/templates/create_jera_push_messages_devices.rb +1 -1
- data/lib/generators/jera_push/templates/jera_push.rb +2 -2
- data/lib/jera_push/firebase/client.rb +1 -39
- data/lib/jera_push/models/push_body.rb +1 -1
- data/lib/jera_push/version.rb +1 -1
- data/lib/jera_push.rb +2 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7236749dd21e8caed1678a8e44c9e00b6e034e1198b9049bf5bc36ba5cee605
|
4
|
+
data.tar.gz: 36f20664f005ad3459f6651ad32ac1094bd1fa9556d198a332005c92363f6138
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e288ec7ce98901ab70ac41a64df9f607117af92f954357cc383191abe4a970da61764367b324d97fad57c95805fc32a4fc0833ed8980a54bf550acd7418e7c
|
7
|
+
data.tar.gz: f33ffb817dc6f3f3491415703559cbeff5a3efc3e3f1aebab38f49b818605befe837d3a52538ec0f5c9ea64c4b8b3e8b7a11f0cb2dcb063bae049441045f14c9
|
@@ -1,10 +1,10 @@
|
|
1
1
|
#this is the intilizer
|
2
2
|
#here you will set up the jera push configuration
|
3
3
|
JeraPush.setup do |config|
|
4
|
-
config.firebase_api_key = "YOUR_API_KEY"
|
5
4
|
# Change this for every new model
|
6
5
|
config.resources_name = ["<%= file_name.classify %>"]
|
7
|
-
|
6
|
+
# You need to create a Account Service on google cloud, with editor permission or administrator. Flow this doc: https://cloud.google.com/iam/docs/service-accounts-create?hl=pt-br
|
7
|
+
config.project_id = "YOUR_PROJECT_ID" # inside of the account service json
|
8
8
|
config.credentials_path = "YOUR_CREDENTIALS_PATH" #https://firebase.google.com/docs/cloud-messaging/migrate-v1?hl=pt-br#provide-credentials-manually
|
9
9
|
######################################################
|
10
10
|
# Resource attribute showed in views #
|
@@ -14,53 +14,15 @@ module JeraPush::Firebase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def send_to_device(push:)
|
17
|
-
@client.send_message("projects/#{::JeraPush.
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_device_to_topic(topic:, device:)
|
21
|
-
send(url: "#{FIREBASE_INSTANCE_ID_URL}/v1/#{device.token}/rel/topics/#{topic}")
|
22
|
-
end
|
23
|
-
|
24
|
-
def remove_device_from_topic(topic:, devices: [])
|
25
|
-
send(
|
26
|
-
url: "#{FIREBASE_INSTANCE_ID_URL}/v1:batchRemove",
|
27
|
-
body: {
|
28
|
-
to: "/topics/#{topic}",
|
29
|
-
registration_tokens: devices.pluck(:token)
|
30
|
-
}.to_json
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
def send_message_to_topic(message:, topic:)
|
35
|
-
send(
|
36
|
-
url: FIREBASE_URL,
|
37
|
-
body: {
|
38
|
-
title: message.title,
|
39
|
-
body: message.body,
|
40
|
-
to: "/topics/#{topic}",
|
41
|
-
priority: 'high'
|
42
|
-
}.to_json
|
43
|
-
)
|
17
|
+
@client.send_message("projects/#{::JeraPush.project_id}", push.to_json, options: { retries: 3, multiplier: 1, max_interval: 2 })
|
44
18
|
end
|
45
19
|
|
46
20
|
private
|
47
21
|
|
48
|
-
def send(url:, body: {})
|
49
|
-
response = HTTParty.post(url, { body: body, headers: default_headers })
|
50
|
-
JSON.parse(response)
|
51
|
-
end
|
52
|
-
|
53
22
|
def fetch_access_token
|
54
23
|
@authorizer.fetch_access_token! if @authorizer.needs_access_token?
|
55
24
|
|
56
25
|
@authorizer
|
57
26
|
end
|
58
|
-
|
59
|
-
def default_headers
|
60
|
-
{
|
61
|
-
"Authorization" => "key=#{::JeraPush.firebase_api_key}",
|
62
|
-
"Content-Type" => "application/json"
|
63
|
-
}
|
64
|
-
end
|
65
27
|
end
|
66
28
|
end
|
@@ -26,7 +26,7 @@ module JeraPush
|
|
26
26
|
self.device = device
|
27
27
|
self.devices = devices
|
28
28
|
self.validate_only = validate_only
|
29
|
-
self.analytics_label = analytics_label
|
29
|
+
self.analytics_label = analytics_label.gsub(/\s/, '_').gsub(/[^a-zA-Z0-9.~%_]/, '').slice(0, 50).downcase
|
30
30
|
self.ios = ios_config
|
31
31
|
self.notification = notification.nil? ? Notification.new(title: title, body: body, image: image) : notification
|
32
32
|
self.android = android_config
|
data/lib/jera_push/version.rb
CHANGED
data/lib/jera_push.rb
CHANGED
@@ -27,11 +27,8 @@ module JeraPush
|
|
27
27
|
autoload :AndroidConfig, 'jera_push/models/android_config.rb'
|
28
28
|
autoload :Notification, 'jera_push/models/notification.rb'
|
29
29
|
|
30
|
-
mattr_accessor :
|
31
|
-
@@
|
32
|
-
|
33
|
-
mattr_accessor :project_name
|
34
|
-
@@project_name = nil
|
30
|
+
mattr_accessor :project_id
|
31
|
+
@@project_id = nil
|
35
32
|
|
36
33
|
mattr_accessor :project_id
|
37
34
|
@@project_id = nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jera_push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|