Skip to content

Commit

Permalink
revert 'json' to 'format' for ios deliveries
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-6 committed Jan 23, 2024
1 parent 590d052 commit 5f7eca8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ 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
4 changes: 2 additions & 2 deletions docs/delivery_methods/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_
class CommentNotification
deliver_by :ios do |config|
config.device_tokens = ->(recipient) { recipient.notification_tokens.where(platform: :iOS).pluck(:token) }
config.json = ->(apn) {
config.format = ->(apn) {
apn.alert = "Hello world"
apn.custom_payload = {url: root_url(host: "example.org")}
}
Expand All @@ -36,7 +36,7 @@ end

## Options

* `json`
* `format`

Customize the Apnotic notification object

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 @@ -32,7 +32,7 @@ def deliver
def format_notification(apn)
apn.topic = evaluate_option(:bundle_identifier)

if (method = config[:json])
if (method = config[:format])
method = event.send(method, apn) if method.is_a?(Symbol) && event.respond_to?(method)
notification.instance_exec(apn, &method)
elsif notification.params.try(:has_key?, :message)
Expand Down
2 changes: 1 addition & 1 deletion test/delivery_methods/ios_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def ok?
team_id: "team_id",
apns_key: "apns_key",
device_tokens: [:a, :b],
json: ->(apn) {
format: ->(apn) {
apn.alert = "Hello world"
apn.custom_payload = {url: root_url(host: "example.org")}
},
Expand Down

0 comments on commit 5f7eca8

Please sign in to comment.