Skip to content

Commit

Permalink
Standardize
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Jan 15, 2024
1 parent 1dacd09 commit e4e6a96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/delivery_methods/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@ end

## Delivering to Sandboxes and real devices

If you wish to send notifications to both sandboxed and real devices from the same application, you can configure two iOS delivery methods
A user has_many tokens that can be generated from both development (sandboxed devices), or production (not sandboxed devices) and is unrelated to the rails environment or endpoint being used. I

```ruby
deliver_by :ios do |config|
config.device_tokens = ->(recipient) { recipient.notification_tokens.where(environment: :production, platform: :iOS).pluck(:token) }
end

deliver_by :ios_development do |config|
deliver_by :ios_development, class: "Noticed::DeliveryMethods::Ios" do |config|
config.development = true
config.device_tokens = ->(recipient) { recipient.notification_tokens.where(environment: :development, platform: :iOS).pluck(:token) }
end
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 @@ -12,7 +12,7 @@ def deliver
apn = Apnotic::Notification.new(device_token)
format_notification(apn)

connection_pool = !!evaluate_option(:development) ? development_pool : production_pool
connection_pool = (!!evaluate_option(:development)) ? development_pool : production_pool
connection_pool.with do |connection|
response = connection.push(apn)
raise "Timeout sending iOS push notification" unless response
Expand Down

0 comments on commit e4e6a96

Please sign in to comment.