Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Updates #374

Merged
merged 10 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ You will need to remove `deliver_by :database` from your notifiers.

For clarity, we've renamed `app/notifications` to `app/notifiers`.

Notifiers - the class that delivers notifications
Notification - the database record of the notification
**Notifiers** - the class that delivers notifications
**Notification** - the database record of the notification

We recommend renaming your existing classes to match. You'll also need to update the `type` column on existing notifications when renaming.

Expand Down Expand Up @@ -93,6 +93,10 @@ class CommentNotifier < Noticed::Event
end
```

### Deliver Later

Notifications are always delivered later now. The `.deliver_later` method has been removed. Instead you can just user `.deliver`

### Required Params

`param` and `params` have been renamed to `required_param(s)` to be more clear.
Expand Down Expand Up @@ -138,6 +142,32 @@ class NewCommentNotifier < Noticed::Event
end
```

#### Notification Model Methods

In order to extend the Noticed models you'll need to use a concern an a to_prepare block:

```ruby
# config/initializers/noticed.rb
module NotificationExtensions
extend ActiveSupport::Concern

included do
belongs_to :organisation

scope :filter_by_type, ->(type) { where(type:) }
scope :exclude_type, ->(type) { where.not(type:) }
end

# You can also add instance methods here
end

Rails.application.config.to_prepare do
# You can extend Noticed::Event or Noticed::Notification here
Noticed::Event.include NotificationExtensions
Noticed::Notification.include NotificationExtensions
end
```

### Has Noticed Notifications

`has_noticed_notifications` has been removed in favor of the `record` polymorphic relationship that can be directly queried with ActiveRecord. You can add the necessary json query to your model(s) to restore the json query if needed.
Expand Down Expand Up @@ -169,7 +199,7 @@ model.where("json_extract(params, ?) = ?", "$.#{param_name}", Noticed::Coder.dum
model.where(params: {param_name.to_sym => self})
```

### Receipient Notifications Association
### Recipient Notifications Association

Recipients can be associated with notifications using the following. This is useful for displaying notifications in your UI.

Expand Down Expand Up @@ -200,6 +230,7 @@ The `invalid_token` option replaces the `cleanup_device_tokens` method for handl

#### iOS

The `cert_path` option has been renamed to `apns_key` and should be given the key and not a path.
The `format` option has been renamed to `json`.
The `device_tokens` option is now required and should return an Array of device tokens.
The `invalid_token` option replaces the `cleanup_device_tokens` method for handling invalid/expired tokens.
Expand Down
2 changes: 1 addition & 1 deletion docs/delivery_methods/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end

## Options

* `format`
* `json`

Customize the Apnotic notification object

Expand Down