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
# File 'lib/notify_user/channels/apns/apns_channel.rb', line 11

def deliver(notification, options={})
  NotifyUser::Apns.push_notification(notification)

  #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::Apns.push_notification(notification)

    #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