diff --git a/docs/delivery_methods/ios.md b/docs/delivery_methods/ios.md index 93047b3c..6a8a28d1 100644 --- a/docs/delivery_methods/ios.md +++ b/docs/delivery_methods/ios.md @@ -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 diff --git a/lib/noticed/delivery_methods/ios.rb b/lib/noticed/delivery_methods/ios.rb index d58e67ca..ccf79dfd 100644 --- a/lib/noticed/delivery_methods/ios.rb +++ b/lib/noticed/delivery_methods/ios.rb @@ -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