notification-pusher-onesignal 1.0.0.beta6 → 1.0.0.beta7

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: 6e563e4986bafdb9a5feee7fe9acd387fc616f071f2821261bfc640984a0fed8
4
- data.tar.gz: 3f88498c398942eac5926a60b7af3532c8cfe8b8c7befce1385d75532eeaeecd
3
+ metadata.gz: 003b9df38484ca164c92cb47a5014d68894bb37f1171c08f5687b86fdbb59d7d
4
+ data.tar.gz: d57471f4ba274e40426ea02dac5d9969de492811c78dded41c567d9b1bb07144
5
5
  SHA512:
6
- metadata.gz: 7d84935a6efd5d96269b493eb01895ee4f981e0d48efdf8dbb9859d53e000de9bc5638fb052bf316edce7fa7c7a58b8e124eca160b46febee4439c4c36329b19
7
- data.tar.gz: 5a8f1e5e3a36c1d7d35ee16c5959d331b81d24f413fb235609669767e38c3ddf762459973454bd88e74931407a4543f5da0aed1c7d139fc434e45613170bbd05
6
+ metadata.gz: 1226b9eb395a46cfdac4ce1251cc96d33da2bf9d84ec05645fe3448a53e362cf96f72370e8d03346d79f3f7968c0aa96e4c1f43af25c1782861c2146cefaad3c
7
+ data.tar.gz: 54822a01148e616edbf3d6a8a9bdd7aaa45593dab74fe231cc5ba09e686ced3398b3a189ec5a645a4cd4ce97a9dea89bf70fa8dc1344aa2afd1af2c537c1cd23
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ ### master
4
+
5
+ * nothing yet
6
+
7
+ ### 1.0.0.beta6 - 2017-12-28
8
+
9
+ * bugfixes
10
+ * fix lib loading problems
11
+
12
+ ### 1.0.0.beta5 - 2017-12-28
13
+
14
+ * no changes
15
+
16
+ ### 1.0.0.beta4 - 2017-12-27
17
+
18
+ * features
19
+ * add functionality
20
+
21
+ ### 1.0.0.beta3 - 2017-12-25
22
+
23
+ * no changes
24
+
25
+ ### 1.0.0.beta2 - 2017-12-23
26
+
27
+ * no changes
28
+
29
+ ### 1.0.0.beta1 - 2017-12-22
30
+
31
+ * initial release
data/README.md CHANGED
@@ -1,17 +1,16 @@
1
- # NotificationsRails
1
+ # NotificationPusher for OneSignal
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/notifications-rails.svg)](https://badge.fury.io/rb/notifications-rails) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
3
+ [![Gem Version](https://badge.fury.io/rb/notification-pusher-onesignal.svg)](https://badge.fury.io/rb/notification-pusher-onesignal) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
4
4
 
5
- The most powerful notification solution for Rails. NotificationsRails simplifies the handling, rendering, user-integration and cross-platform pushing of notifications through its simple API.
6
-
7
- It integrates with the [Native](https://github.com/NativeGap/native-rails) gem to allow you to create a cross platform Rails app.
5
+ A pusher to send cross-platform notifications with OneSignal.
8
6
 
9
7
  ---
10
8
 
11
9
  ## Table of Contents
12
10
 
13
- * [Philosophy](#philosophy)
14
11
  * [Installation](#installation)
12
+ * [Usage](#usage)
13
+ * [Options](#options)
15
14
  * [To Do](#to-do)
16
15
  * [Contributing](#contributing)
17
16
  * [Contributors](#contributors)
@@ -20,49 +19,84 @@ It integrates with the [Native](https://github.com/NativeGap/native-rails) gem t
20
19
 
21
20
  ---
22
21
 
23
- ## Philosophy
22
+ ## Installation
23
+
24
+ NotificationPusher for OneSignal works with Rails 5 onwards. You can add it to your `Gemfile` with:
24
25
 
25
- NotificationsRails has been built with modularity in mind. It currently consists of four components each of which bringing one essential functionality to the notification-integration in your Rails app.
26
+ ```ruby
27
+ gem 'notification-pusher-onesignal'
28
+ ```
29
+
30
+ And then execute:
26
31
 
27
- **[NotificationHandler](notification-handler):** Create and modify your notifications through a simple API.
32
+ $ bundle
28
33
 
29
- **[NotificationRenderer](notification-renderer):** Render your notifications on multiple platforms by specifying notification types.
34
+ Or install it yourself as:
30
35
 
31
- **[NotificationPusher](notification-pusher):** Push your notifications to various services. Including [Email](notification-pusher-actionmailer), [ActionCable](notification-pusher-actioncable), [OneSignal](notification-pusher-onesignal).
36
+ $ gem install notification-pusher-onesignal
32
37
 
33
- **[NotificationSettings](notification-settings):** Integrates with your authentication solution to craft a personalized user notification platform.
38
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
34
39
 
35
- You may just add the components you actually need, or instead use this gem to bundle everything for a complete notification solution.
40
+ ```ruby
41
+ gem 'notification-pusher-onesignal', github: 'jonhue/notifications-rails'
42
+ ```
36
43
 
37
44
  ---
38
45
 
39
- ## Installation
46
+ ## Usage
40
47
 
41
- NotificationsRails works with Rails 5 onwards. You can add it to your `Gemfile` with:
48
+ Define this pusher in your `NotificationPusher` configuration:
42
49
 
43
50
  ```ruby
44
- gem 'notifications-rails'
51
+ NotificationPusher.configure do |config|
52
+    config.define_pusher :OneSignal, app_id: 'f158a844-9f3c-4207-b246-e93603b0a970', auth_key: 'kODc3N2ItOTNC00NGzOGYtMzI5OWQ3ZmQ'
53
+ end
45
54
  ```
46
55
 
47
- And then execute:
56
+ Now you can push your notifications to OneSignal:
48
57
 
49
- $ bundle
58
+ ```ruby
59
+ notification = Notification.create target: User.first, object: Recipe.first
60
+ notification.push :OneSignal, player_ids: ['f158a844-9f3c-4207-b246-e93603b0a970'], url: Rails.application.routes.url_helpers.root_url, contents: {
61
+    en: notification.object.title
62
+ }
63
+ ```
50
64
 
51
- Or install it yourself as:
65
+ To get player id's you could use the [devise-onesignal](https://github.com/jonhue/devise-onesignal) gem. This is how that would look:
52
66
 
53
- $ gem install notifications-rails
67
+ ```ruby
68
+ notification.push :OneSignal, player_ids: User.first.onesignal_player_ids
69
+ ```
54
70
 
55
- If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
71
+ You can also store OneSignal information in your notification opposed to specifying it when pushing:
56
72
 
57
73
  ```ruby
58
- gem 'notifications-rails', github: 'jonhue/notifications-rails'
74
+ notification.metadata[:onesignal_url] = Rails.application.routes.url_helpers.root_url
75
+ notification.metadata[:onesignal_contents] = {
76
+    en: 'My notification'
77
+ }
78
+ notification.save
79
+ notification.push :OneSignal, player_ids: User.first.onesignal_player_ids
59
80
  ```
60
81
 
82
+
83
+ ### Options
84
+
85
+ **`app_id` (required)** OneSignal App ID. Takes a string.
86
+
87
+ **`auth_key` (required)** OneSignal API authentication key. Takes a string.
88
+
89
+ **`player_ids`** Array of OneSignal Player ID's a notification should be pushed to. Takes an array of strings.
90
+
91
+ **`url`** Specify a URL for this notification. Takes a string.
92
+
93
+ **`contents`** Globalized content of the notification. Takes a hash with languages as keys and strings as values.
94
+
61
95
  ---
62
96
 
63
97
  ## To Do
64
98
 
65
- [Here](https://github.com/jonhue/notifications-rails/projects) is the full list of current projects.
99
+ [Here](https://github.com/jonhue/notifications-rails/projects/7) is the full list of current projects.
66
100
 
67
101
  To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
68
102
 
@@ -70,9 +104,9 @@ To propose your ideas, initiate the discussion by adding a [new issue](https://g
70
104
 
71
105
  ## Contributing
72
106
 
73
- We hope that you will consider contributing to NotificationsRails. Please read this short overview for some information about how to get started:
107
+ We hope that you will consider contributing to NotificationPusher for OneSignal. Please read this short overview for some information about how to get started:
74
108
 
75
- [Learn more about contributing to this repository](CONTRIBUTING.md), [Code of Conduct](CODE_OF_CONDUCT.md)
109
+ [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)
76
110
 
77
111
  ### Contributors
78
112
 
@@ -82,7 +116,7 @@ https://github.com/jonhue/notifications-rails/graphs/contributors
82
116
 
83
117
  ### Semantic Versioning
84
118
 
85
- NotificationsRails follows Semantic Versioning 2.0 as defined at http://semver.org.
119
+ NotificationPusher for OneSignal follows Semantic Versioning 2.0 as defined at http://semver.org.
86
120
 
87
121
  ## License
88
122
 
@@ -0,0 +1,5 @@
1
+ module NotificationPusher
2
+
3
+ require 'notification_pusher/one_signal'
4
+
5
+ end
@@ -0,0 +1,16 @@
1
+ module NotificationPusher
2
+ class OneSignal
3
+
4
+ def initialize notification, options = {}
5
+ if options[:player_ids].any?
6
+ OneSignal::Notification.create params: {
7
+ app_id: options[:app_id],
8
+ url: options[:url] || notification.metadata[:onesignal_url],
9
+ contents: options[:contents] || notification.metadata[:onesignal_contents].to_h,
10
+ include_player_ids: options[:player_ids]
11
+ }, opts: { auth_key: options[:auth_key] }
12
+ end
13
+ end
14
+
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notification-pusher-onesignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta6
4
+ version: 1.0.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0.beta6
33
+ version: 1.0.0.beta7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0.beta6
40
+ version: 1.0.0.beta7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,8 +72,11 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
+ - CHANGELOG.md
75
76
  - LICENSE
76
77
  - README.md
78
+ - lib/notification_pusher.rb
79
+ - lib/notification_pusher/one_signal.rb
77
80
  homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher/notification-pusher-onesignal
78
81
  licenses:
79
82
  - MIT
@@ -81,7 +84,7 @@ metadata: {}
81
84
  post_install_message:
82
85
  rdoc_options: []
83
86
  require_paths:
84
- - lib/notification_pusher.rb
87
+ - lib
85
88
  required_ruby_version: !ruby/object:Gem::Requirement
86
89
  requirements:
87
90
  - - ">="