Skip to content

Commit

Permalink
Merge branch 'main' of github.com:excid3/noticed
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Feb 23, 2024
2 parents d941204 + 294679f commit d054cc9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
### Unreleased

* Fix iOS `format` option with Symbols. This now passes the `notification` and `apn` objects instead of just the `apn`.

```ruby
config.format = :ios_format

# ...
def ios_format(notification, apn)
end
```

### 2.1.3

* Stringify keys for Twilio Messaging json
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ module IosNotifier
config.key_id = Rails.application.credentials.dig(:ios, :key_id)
config.team_id = Rails.application.credentials.dig(:ios, :team_id)
config.apns_key = Rails.application.credentials.dig(:ios, :apns_key)
config.if = ->(recipient) { recipient.ios_notifications? }
config.if = -> { recipient.ios_notifications? }
end
end
end
Expand Down Expand Up @@ -387,15 +387,15 @@ This invocation will create a single `Noticed::Event` record and a `Noticed::Not

### Custom Noticed Model Methods

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

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

included do
belongs_to :organisation
belongs_to :organization

scope :filter_by_type, ->(type) { where(type:) }
scope :exclude_type, ->(type) { where.not(type:) }
Expand Down Expand Up @@ -766,7 +766,7 @@ class CreateNoticedTables < ActiveRecord::Migration[7.1]
t.jsonb :params

# Custom Fields
t.string :organisation_id, type: :uuid, as: "((params ->> 'organisation_id')::uuid)", stored: true
t.string :organization_id, type: :uuid, as: "((params ->> 'organization_id')::uuid)", stored: true
t.virtual :action_type, type: :string, as: "((params ->> 'action_type'))", stored: true
t.virtual :url, type: :string, as: "((params ->> 'url'))", stored: true

Expand Down
2 changes: 1 addition & 1 deletion lib/noticed/delivery_methods/ios.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def format_notification(apn)
method = config[:format]
# Call method on Notifier if defined
if method&.is_a?(Symbol) && event.respond_to?(method)
event.send(method, apn)
event.send(method, notification, apn)
# If Proc, evaluate it on the Notification
elsif method&.respond_to?(:call)
notification.instance_exec(apn, &method)
Expand Down

0 comments on commit d054cc9

Please sign in to comment.