notification-pusher-onesignal 2.0.0 → 4.0.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: 5e0d569e256c162ee1e9ec709b2a324a6371da9dda921377ffb8221edcbe4e9f
4
- data.tar.gz: b228cbdeacaf05e420b4ae32774703f654f4d64f53810d57aa80529a071c017f
3
+ metadata.gz: c4a7571c13dff52d7dd4db1fdb9e24372e4f9b2a5a60b9dfbd80677d0e1257f8
4
+ data.tar.gz: adcfa042e05403dc2a0afdce6d0c274dbce61275886505a21dac5c2355fda780
5
5
  SHA512:
6
- metadata.gz: 236b9a2b53d1547a0316b386e3cbe975b13bc641e551bb2a61168685810850cb6d4d8ac63e08f31bcaa57b9740ac57ea04bfedccb0a5a3b53d72047dd569689f
7
- data.tar.gz: 51a5fadd33ca0e67d92136741cc8a2da7751ae7275cf645aa2a99cfdfdfa502f23fc572ee2c08557c8e3c86b40f797f9e50821ca009b73ee9abb7dfafb40b582
6
+ metadata.gz: 487d9e91b85b13346780f5b6035592d0c8d8ecb67476803ad78f19f03baabcf5b6dfdb26bc89bb114189ca9af821e66fb60aeb412743e248d36db90e3d0fe6c3
7
+ data.tar.gz: 8267a103a8cbf1a5fc171c7dddf24a1e5d9d6b31cc1a87d588ad245942f6b829b697df0c9479f773e99c971b969bd12c5cdfab307282d33e4d81d9cbc3896403
data/README.md CHANGED
@@ -1,109 +1,84 @@
1
- # NotificationPusher for OneSignal
1
+ # notifications-rails
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/notification-pusher-onesignal.svg)](https://badge.fury.io/rb/notification-pusher-onesignal) ![Travis](https://travis-ci.com/jonhue/notifications-rails.svg?branch=master)
3
+ A flexible notification library supporting the delivery to external services, rendering in various environments, and user configuration by category.
4
4
 
5
- A pusher to send cross-platform notifications with OneSignal.
5
+ ## Philosophy
6
6
 
7
- ---
7
+ notifications-rails has been built with modularity in mind. It currently consists of four components each of which bringing one essential functionality to the integration of notifications in your Rails app.
8
8
 
9
- ## Table of Contents
9
+ **[notification-handler](notification-handler):** Create and modify your notifications through a simple API.
10
10
 
11
- * [Installation](#installation)
12
- * [Usage](#usage)
13
- * [Options](#options)
14
- * [To Do](#to-do)
15
- * [Contributing](#contributing)
16
- * [Semantic versioning](#semantic-versioning)
11
+ **[notification-renderer](notification-renderer):** Render your notifications in various contexts.
17
12
 
18
- ---
13
+ **[notification-pusher](notification-pusher):** Deliver your notifications to various services, including [Email](notification-pusher/notification-pusher-actionmailer) and [OneSignal](notification-pusher/notification-pusher-onesignal).
14
+
15
+ **[notification-settings](notification-settings):** Integrates with your authentication solution to craft a personalized user notification platform.
16
+
17
+ You may just use the components you actually need, or instead use this gem to bundle everything for a complete notification solution.
19
18
 
20
19
  ## Installation
21
20
 
22
- NotificationPusher for OneSignal works with Rails 5 onwards. You can add it to your `Gemfile` with:
21
+ You can add notifications-rails to your `Gemfile` with:
23
22
 
24
23
  ```ruby
25
- gem 'notification-pusher-onesignal'
24
+ gem 'notifications-rails'
26
25
  ```
27
26
 
28
- And then execute:
27
+ And then run:
29
28
 
30
- $ bundle
29
+ $ bundle install
31
30
 
32
31
  Or install it yourself as:
33
32
 
34
- $ gem install notification-pusher-onesignal
35
-
36
- ---
37
-
38
- ## Usage
39
-
40
- Register this delivery method in your `NotificationPusher` configuration:
33
+ $ gem install notifications-rails
41
34
 
42
- ```ruby
43
- NotificationPusher.configure do |config|
44
- config.register_delivery_method :one_signal, :OneSignal, app_id: 'f158a844-9f3c-4207-b246-e93603b0a970', auth_key: 'kODc3N2ItOTNC00NGzOGYtMzI5OWQ3ZmQ'
45
- end
46
- ```
47
-
48
- Now you can deliver your notifications through OneSignal:
35
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
49
36
 
50
37
  ```ruby
51
- notification = Notification.create(target: User.first, object: Recipe.first)
52
- notification.deliver(:one_signal, player_ids: ['f158a844-9f3c-4207-b246-e93603b0a970'], url: Rails.application.routes.url_helpers.root_url, contents: {
53
- en: notification.object.title
54
- })
38
+ gem 'notifications-rails', github: 'jonhue/notifications-rails'
55
39
  ```
56
40
 
57
- To get player id's you could use the [OnSignal](https://github.com/jonhue/onsignal-rails) gem. This is how that would look:
58
-
59
- ```ruby
60
- notification.deliver(:one_signal, player_ids: notification.target.onesignal_player_ids)
61
- ```
62
-
63
- You can also store OneSignal information in your notification opposed to specifying it when pushing:
64
-
65
- ```ruby
66
- notification.metadata[:onesignal_url] = Rails.application.routes.url_helpers.root_url
67
- notification.metadata[:onesignal_contents] = { en: 'My notification content' }
68
- notification.metadata[:onesignal_headings] = { en: 'My notification header' }
69
- notification.metadata[:onesignal_subtitle] = { en: 'My notification subtitle' }
70
- notification.save!
71
- notification.deliver(:one_signal, player_ids: notification.target.onesignal_player_ids)
72
- ```
41
+ ## Usage
73
42
 
43
+ Details on usage are provided in the [documentation](#philosophy) of the specific modules.
74
44
 
75
- ### Options
45
+ ## Development
76
46
 
77
- **`app_id` (required)** OneSignal App ID. Takes a string.
47
+ To start development you first have to fork this repository and locally clone your fork.
78
48
 
79
- **`auth_key` (required)** OneSignal API authentication key. Takes a string.
49
+ Install the projects dependencies by running:
80
50
 
81
- **`player_ids`** Array of OneSignal Player ID's a notification should be pushed to. Takes an array of strings.
51
+ $ bundle install
82
52
 
83
- **`url`** Specify a URL for this notification. Takes a string.
53
+ ### Testing
84
54
 
85
- **`contents`** Globalized content of the notification. Takes a hash with languages as keys and strings as values.
55
+ Tests are written with RSpec. Integration tests are located in `/spec`, unit tests can be found in `<module>/spec`.
86
56
 
87
- **`headings`** Globalized header of the notification. Takes a hash with languages as keys and strings as values.
57
+ To run all tests:
88
58
 
89
- **`subtitle`** Globalized subtitle of the notification. Takes a hash with languages as keys and strings as values.
59
+ $ ./rspec
90
60
 
91
- ---
61
+ To run RuboCop:
92
62
 
93
- ## To Do
63
+ $ bundle exec rubocop
94
64
 
95
- We use [GitHub projects](https://github.com/jonhue/notifications-rails/projects/7) to coordinate the work on this project.
65
+ You can find all commands run by the CI workflow in `.github/workflows/ci.yml`.
96
66
 
97
- To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
67
+ ## Contributing
98
68
 
99
- ---
69
+ We warmly welcome everyone who is intersted in contributing. Please reference our [contributing guidelines](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md).
100
70
 
101
- ## Contributing
71
+ ## Releases
102
72
 
103
- We hope that you will consider contributing to NotificationPusher for OneSignal. Please read this short overview for some information about how to get started:
73
+ [Here](https://github.com/jonhue/notifications-rails/releases) you can find details on all past releases. Unreleased breaking changes that are on the current master can be found [here](CHANGELOG.md).
104
74
 
105
- [Learn more about contributing to this repository](https://github.com/jonhue/notifications-rails/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/jonhue/notifications-rails/blob/master/CODE_OF_CONDUCT.md)
75
+ notifications-rails follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our [security policy](SECURITY.md).
106
76
 
107
- ### Semantic Versioning
77
+ ### Publishing
108
78
 
109
- NotificationPusher for OneSignal follows Semantic Versioning 2.0 as defined at http://semver.org.
79
+ 1. Review breaking changes and deprecations in `CHANGELOG.md`.
80
+ 1. Change the gem version in `VERSION`.
81
+ 1. Reset `CHANGELOG.md`.
82
+ 1. Create a pull request to merge the changes into `master`.
83
+ 1. After the pull request was merged, create a new release listing the breaking changes and commits on `master` since the last release.
84
+ 1. The release workflow will publish the gems to RubyGems.
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'notification-handler'
4
+ require 'notification-renderer'
5
+ require 'notification-pusher'
6
+ require 'notification-settings'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notification-pusher-onesignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-04 00:00:00.000000000 Z
11
+ date: 2022-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: notification-pusher
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: one_signal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -136,20 +136,21 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description: A pusher to send cross-platform notifications with OneSignal.
140
- email: me@jonhue.me
139
+ description: A delivery method to send your notifications to devices on all platforms
140
+ with OneSignal.
141
+ email: jonas.huebotter@gmail.com
141
142
  executables: []
142
143
  extensions: []
143
144
  extra_rdoc_files: []
144
145
  files:
145
146
  - LICENSE
146
147
  - README.md
147
- - lib/notification-pusher-onesignal.rb
148
- - lib/notification_pusher/delivery_method/one_signal.rb
148
+ - lib/notifications-rails.rb
149
149
  homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher/notification-pusher-onesignal
150
150
  licenses:
151
151
  - MIT
152
- metadata: {}
152
+ metadata:
153
+ github_repo: ssh://github.com/jonhue/notifications-rails
153
154
  post_install_message:
154
155
  rdoc_options: []
155
156
  require_paths:
@@ -158,15 +159,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
159
  requirements:
159
160
  - - ">="
160
161
  - !ruby/object:Gem::Version
161
- version: 2.2.2
162
+ version: '2.7'
162
163
  required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  requirements:
164
165
  - - ">="
165
166
  - !ruby/object:Gem::Version
166
167
  version: '0'
167
168
  requirements: []
168
- rubygems_version: 3.0.3
169
+ rubygems_version: 3.3.7
169
170
  signing_key:
170
171
  specification_version: 4
171
- summary: A pusher to send cross-platform notifications with OneSignal
172
+ summary: A delivery method to send your notifications to devices on all platforms
173
+ with OneSignal
172
174
  test_files: []
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'one_signal'
4
- require 'notification-pusher'
5
- require_relative 'notification_pusher/delivery_method/one_signal'
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NotificationPusher
4
- module DeliveryMethod
5
- class OneSignal < NotificationPusher::DeliveryMethod::Base
6
- def call
7
- return unless options[:player_ids].any?
8
-
9
- ::OneSignal::Notification.create params: {
10
- app_id: options[:app_id],
11
- url: url_param,
12
- contents: contents_param,
13
- headings: headings_param,
14
- subtitle: subtitle_param,
15
- include_player_ids: options[:player_ids]
16
- }, opts: { auth_key: options[:auth_key] }
17
- end
18
-
19
- private
20
-
21
- def url_param
22
- options[:url] || notification.metadata[:onesignal_url].to_h
23
- end
24
-
25
- def contents_param
26
- options[:contents] || notification.metadata[:onesignal_contents].to_h
27
- end
28
-
29
- def headings_param
30
- options[:headings] || notification.metadata[:onesignal_headings].to_h
31
- end
32
-
33
- def subtitle_param
34
- options[:subtitle] || notification.metadata[:onesignal_subtitle].to_h
35
- end
36
- end
37
- end
38
- end