notification-pusher-onesignal 1.0.0.beta6 → 1.0.0.beta7
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/CHANGELOG.md +31 -0
- data/README.md +60 -26
- data/lib/notification_pusher.rb +5 -0
- data/lib/notification_pusher/one_signal.rb +16 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 003b9df38484ca164c92cb47a5014d68894bb37f1171c08f5687b86fdbb59d7d
|
4
|
+
data.tar.gz: d57471f4ba274e40426ea02dac5d9969de492811c78dded41c567d9b1bb07144
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
1
|
+
# NotificationPusher for OneSignal
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/notification-pusher-onesignal) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
|
4
4
|
|
5
|
-
|
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
|
-
##
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
NotificationPusher for OneSignal works with Rails 5 onwards. You can add it to your `Gemfile` with:
|
24
25
|
|
25
|
-
|
26
|
+
```ruby
|
27
|
+
gem 'notification-pusher-onesignal'
|
28
|
+
```
|
29
|
+
|
30
|
+
And then execute:
|
26
31
|
|
27
|
-
|
32
|
+
$ bundle
|
28
33
|
|
29
|
-
|
34
|
+
Or install it yourself as:
|
30
35
|
|
31
|
-
|
36
|
+
$ gem install notification-pusher-onesignal
|
32
37
|
|
33
|
-
|
38
|
+
If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
|
34
39
|
|
35
|
-
|
40
|
+
```ruby
|
41
|
+
gem 'notification-pusher-onesignal', github: 'jonhue/notifications-rails'
|
42
|
+
```
|
36
43
|
|
37
44
|
---
|
38
45
|
|
39
|
-
##
|
46
|
+
## Usage
|
40
47
|
|
41
|
-
|
48
|
+
Define this pusher in your `NotificationPusher` configuration:
|
42
49
|
|
43
50
|
```ruby
|
44
|
-
|
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
|
-
|
56
|
+
Now you can push your notifications to OneSignal:
|
48
57
|
|
49
|
-
|
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
|
-
|
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
|
-
|
67
|
+
```ruby
|
68
|
+
notification.push :OneSignal, player_ids: User.first.onesignal_player_ids
|
69
|
+
```
|
54
70
|
|
55
|
-
|
71
|
+
You can also store OneSignal information in your notification opposed to specifying it when pushing:
|
56
72
|
|
57
73
|
```ruby
|
58
|
-
|
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
|
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
|
-
|
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,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.
|
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.
|
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.
|
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
|
87
|
+
- lib
|
85
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
89
|
requirements:
|
87
90
|
- - ">="
|