简体   繁体   中英

Undefined method 'notify' when using APN_Sender with Sidekiq

i'm having a bit of trouble in sending those push notifications using APN_SENDER gem ( https://github.com/arthurnn/apn_sender ).

When "notify_async(ids,opts)" is called i get the following error:

NoMethodError (undefined method `notify' for :sidekiq:Symbol):

Here's the code

def self.send_apple_push_notification(projeto, ids, message)
 projeto.configure_apn(projeto)
 options = { alert: message, badge: "+1", sound: true, other_information: ''}
 ids.each do |id|
   APN.notify_async(id, options)
 end
end

I've chosen sidekiq as my backend just like the README suggests

APN.backend = :sidekiq # use sidekiq backend

Here's the rest of the configuration. This was done with the intent to make the project work with multiple certificates.

    def configure_apn(projeto)
      path = nil
      if projeto.desenvolvimento
        path = projeto.apn_development.path
      else
        path = projeto.apn_production.path
      end

      unless path.nil?
        last_slash = path.rindex("/")
        folder = path[0..last_slash]
        file = path[last_slash+1..path.length]

    APN.root = folder # root to certificates folder
    APN.certificate_name = file # certificate filename
    if projeto.desenvolvimento
      APN.host = projeto.apn_host
      APN.password = projeto.apn_password_development
    else
      APN.password = projeto.apn_password_production
    end
    APN.pool_size = 1 # number of connections on the pool
    APN.pool_timeout = 5 # timeout in seconds for connection pool
    APN.logger = Logger.new(File.join(Rails.root, 'log', 'apn_sender.log'))
    APN.truncate_alert = true 
    APN.backend = :sidekiq # use sidekiq backend
  end
end

This issue has been resolved in the new release version v2.1.1

Refer https://github.com/arthurnn/apn_sender/issues/92

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM