Skip to content

Commit

Permalink
Merge pull request #126 from crafterm/feature/dismissal_date
Browse files Browse the repository at this point in the history
Live activity `dismissal_date` key support
  • Loading branch information
ostinelli authored Apr 10, 2024
2 parents 80bba00 + e0a84c9 commit 4b0f851
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ These are all Accessor attributes.
| `content_state` | Refer to [Payload Key Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363) for details. iOS 16+
| `timestamp` | Refer to [Payload Key Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363) for details. iOS 16+
| `event` | Refer to [Payload Key Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363) for details. iOS 16+
| `dismissal_date` | Refer to [Payload Key Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363) for details. iOS 16+
| `apns_id` | Refer to [Communicating with APNs](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for details.
| `expiration` | "
| `priority` | "
Expand Down
3 changes: 2 additions & 1 deletion lib/apnotic/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Apnotic
class Notification < AbstractNotification
attr_accessor :alert, :badge, :sound, :content_available, :category, :custom_payload, :url_args, :mutable_content, :thread_id
attr_accessor :target_content_id, :interruption_level, :relevance_score
attr_accessor :stale_date, :content_state, :timestamp, :event
attr_accessor :stale_date, :content_state, :timestamp, :event, :dismissal_date

def background_notification?
aps.count == 1 && aps.key?('content-available') && aps['content-available'] == 1
Expand All @@ -30,6 +30,7 @@ def aps
result.merge!('content-state' => content_state) if content_state
result.merge!('timestamp' => timestamp) if timestamp
result.merge!('event' => event) if event
result.merge!('dismissal-date' => dismissal_date) if dismissal_date
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/apnotic/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
notification.content_state = { content: "content" }
notification.timestamp = 1168364460
notification.event = "update"
notification.dismissal_date = 1168364461
end

it { is_expected.to eq (
Expand All @@ -141,6 +142,7 @@
'content-state' => { content: "content" },
'timestamp' => 1168364460,
'event' => 'update',
'dismissal-date' => 1168364461,
},
acme1: "bar"
}.to_json
Expand Down

0 comments on commit 4b0f851

Please sign in to comment.