Class: ApnsChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/notify_user/channels/apns/apns_channel.rb

Class Method Summary collapse

Class Method Details

.default_optionsObject



5
6
7
8
9
# File 'lib/notify_user/channels/apns/apns_channel.rb', line 5

def default_options
  {
    description: "Push Notifications"
  }
end

.deliver(notification, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/notify_user/channels/apns/apns_channel.rb', line 11

def deliver(notification, options={})
  case NotifyUser.apns_provider
  when :houston
    NotifyUser::Houston.new(notification, options).push
  when :urban_airship
    # Check for the existence of development api keys and resend for development:
    if !ENV['DEV_UA_APPLICATION_KEY'].nil? && !ENV['DEV_UA_APPLICATION_SECRET'].nil? && !ENV['DEV_UA_MASTER_SECRET'].nil?

      Urbanairship.application_key = ENV['DEV_UA_APPLICATION_KEY']
      Urbanairship.application_secret = ENV['DEV_UA_APPLICATION_SECRET']
      Urbanairship.master_secret = ENV['DEV_UA_MASTER_SECRET']

      NotifyUser::UrbanAirship.new(notification).push

      # Sets the api keys back to their original state:

      Urbanairship.application_key = ENV['UA_APPLICATION_KEY']
      Urbanairship.application_secret = ENV['UA_APPLICATION_SECRET']
      Urbanairship.master_secret = ENV['UA_MASTER_SECRET']
    end
  end
end