inova_fcm 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a5c3f2db558546de2db1fbc8e5bd1ec590c503888c793de28fa9c5011381b28
4
- data.tar.gz: ccb4df677e12bf71a44215580e7c255536797a043fd17133ea3744061b372424
3
+ metadata.gz: cf8a7122099b2f411a962d6a135e8660bea0d6a538be7109c31d9c174eac2abb
4
+ data.tar.gz: e1252852c68bc45035b142d56d6017ed59b4dcc7edcf18ac87af63475236f9d0
5
5
  SHA512:
6
- metadata.gz: 9a32fce4e8763f73aedc990aebd72859dbd90e4acdaa2d62e53cf41d9d1b2fa9db2a23d3c5329072bcdd8a42512d76847c898495920a5a2dbc1548c5717e8329
7
- data.tar.gz: b7f361981e123ef2575077670747b11c8bcc25fff5c3173b4efda7b4f0cc819c234e2d7f1844970f87ae9846781c14a100c3ce7e526b98bfa0cceaa1a1ef1fb7
6
+ metadata.gz: e82e3d3fd06ae6e492459e60dc78ef3652e9c96cc06d74e3a25821d413f711f662b98353dd36862571e66be1b86710e610673a1a326857a2eedfcb1d49524385
7
+ data.tar.gz: fc23602b6cb7d1144688a7d7bf533bbb80fe7ecaf8f7e225f987fd94b6be6aa7782b3726931a78874aa454c5ea6b015ee18e2082b42abc4f1d41b4f1551e42ae
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
- ## [Unreleased]
1
+ # Changelog
2
2
 
3
- ## [0.1.0] - 2023-12-06
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
- - Initial release
5
+ ## [0.2.0] - 2023-12-28
6
+
7
+ ### Added
8
+
9
+ - Handled the imposed Firebase limit for topic subscription by managing registration and unregistration in batches of 1000.
10
+
11
+ ### Changed
12
+
13
+ - No breaking changes.
14
+ - Minor enhancements for better maintainability.
15
+
16
+ ## [0.1.0] - Initial Release - 2023-12-06
17
+
18
+ ### Added
19
+
20
+ - Initial version of the gem.
data/README.md CHANGED
@@ -7,13 +7,13 @@ InovaFCM is a Ruby gem designed to simplify interactions with Firebase Cloud Mes
7
7
  To use this gem in your project, add it to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'inova_fcm', '~> 0.1.0'
10
+ gem 'inova_fcm', '~> 0.2.0'
11
11
  ```
12
12
 
13
13
  Alternatively, you can install the gem directly using:
14
14
 
15
15
  ```bash
16
- gem install inova_fcm -v '~> 0.1.0'
16
+ gem install inova_fcm -v '~> 0.2.0'
17
17
  ```
18
18
 
19
19
  ## Requirments
@@ -27,7 +27,7 @@ gem install inova_fcm -v '~> 0.1.0'
27
27
  rails generate inova_fcm:install
28
28
  ```
29
29
 
30
- This will create a configuration file at config/initializers/inova_aws_s3.rb. Open the file and set your AWS credentials:
30
+ This will create a configuration file at config/initializers/inova_fcm.rb. Open the file and set your Firebase credentials:
31
31
 
32
32
  ```ruby
33
33
  InovaFCM.configure do |config|
@@ -38,7 +38,17 @@ InovaFCM.configure do |config|
38
38
  end
39
39
  ```
40
40
 
41
- Replace the placeholder values with your actual AWS credentials.
41
+ Replace the placeholder values with your actual Firebase credentials.
42
+
43
+ To send a notification to a device, you can use the following method:
44
+
45
+ ```ruby
46
+ InovaFCM::Service.new(registration_ids: ["registration_id"],
47
+ notification: {title: "tite", body: "body"},
48
+ data: {id: 1}).send_notification
49
+ ```
50
+
51
+ Where registration_ids is an array of device registration ids, notification is a hash containing the notification's title and body, and data is a hash of data to be sent with the notification.
42
52
 
43
53
  ## Contributing
44
54
 
@@ -50,4 +60,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
50
60
 
51
61
  ## Code of Conduct
52
62
 
53
- Everyone interacting in the InovaAwsS3 project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ahmedmos3ad/inova_fcm/blob/master/CODE_OF_CONDUCT.md).
63
+ Everyone interacting in the InovaFCM project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ahmedmos3ad/inova_fcm/blob/master/CODE_OF_CONDUCT.md).
@@ -3,6 +3,8 @@ module InovaFCM
3
3
  require "fcm"
4
4
  require "json"
5
5
 
6
+ MAX_TOPIC_REGISTRATION_BATCH_SIZE = 1000
7
+
6
8
  attr_reader :registration_ids, :notification, :data, :topic
7
9
 
8
10
  def initialize(registration_ids: [], notification: {}, data: {}, topic: SecureRandom.uuid + Time.now.to_i.to_s)
@@ -58,11 +60,15 @@ module InovaFCM
58
60
  end
59
61
 
60
62
  def register_tokens_to_topic
61
- @fcm.batch_topic_subscription(@topic, @registration_ids)
63
+ @registration_ids.each_slice(MAX_TOPIC_REGISTRATION_BATCH_SIZE) do |registration_ids_batch|
64
+ @fcm.batch_topic_subscription(@topic, registration_ids_batch)
65
+ end
62
66
  end
63
67
 
64
68
  def unregister_tokens_from_topic
65
- @fcm.batch_topic_unsubscription(@topic, @registration_ids)
69
+ @registration_ids.each_slice(MAX_TOPIC_REGISTRATION_BATCH_SIZE) do |registration_ids_batch|
70
+ @fcm.batch_topic_unsubscription(@topic, registration_ids_batch)
71
+ end
66
72
  end
67
73
 
68
74
  def validate_attributes!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InovaFCM
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inova_fcm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmed Mos`ad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-06 00:00:00.000000000 Z
11
+ date: 2023-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails