Skip to content

[ERROR] NoMethodError, undefined method `to_binary' for Rapns::Notification #189

Closed
maricris-sn opened this Issue Dec 17, 2013 · 4 comments

2 participants

@maricris-sn

Hi,

I need some advice how to troubleshoot this. I have followed the necessary instructions. Certificates are in place, app, devices and notifications are okay. When I run

bundle exec rapns development -f

I get this:


[2013-12-17 14:18:05] [myapp] Started, 1 handler.
[2013-12-17 14:18:08] [myapp] Connected to gateway.sandbox.push.apple.com:2195
[2013-12-17 14:18:08] [ERROR] NoMethodError, undefined method
to_binary' for #Rapns::Notification:0x007fbf10418418
/Users/chris/Work/myapp/vendor/ruby/1.9.1/gems/activemodel-3.1.12/lib/active_model/attribute_methods.rb:385:in method_missing'
/Users/chris/Work/myapp/vendor/ruby/1.9.1/gems/activerecord-3.1.12/lib/active_record/attribute_methods.rb:60:in
method_missing'
/Users/chris/Work/myapp/vendor/ruby/1.9.1/bundler/gems/rapns-bc59e42f0621/lib/rapns/daemon/apns/delivery.rb:28:in perform'
/Users/chris/Work/myapp/vendor/ruby/1.9.1/bundler/gems/rapns-bc59e42f0621/lib/rapns/daemon/apns/delivery_handler.rb:17:in
deliver'
/Users/chris/Work/myapp/vendor/ruby/1.9.1/bundler/gems/rapns-bc59e42f0621/lib/rapns/daemon/delivery_handler.rb:42:in handle_next_notification'
/Users/chris/Work/myapp/vendor/ruby/1.9.1/bundler/gems/rapns-bc59e42f0621/lib/rapns/daemon/delivery_handler.rb:13:in
block (2 levels) in start'
/Users/chris/Work/myapp/vendor/ruby/1.9.1/bundler/gems/rapns-bc59e42f0621/lib/rapns/daemon/delivery_handler.rb:12:in loop'
/Users/chris/Work/myapp/vendor/ruby/1.9.1/bundler/gems/rapns-bc59e42f0621/lib/rapns/daemon/delivery_handler.rb:12:in
block in start'
[2013-12-17 14:18:08] [myapp] Connected to feedback.sandbox.push.apple.com:2196
`

I'm on:

Rails 3.1.12
Ruby 1.9.3-p125
Rapns 3.5.0

Any help would be appreciated. Thank you!

@ileitch
Owner
ileitch commented Dec 17, 2013

How did you create the notification? It looks like you may have used Rapns::Notification instead of Rapns::Apns::Notification.

@maricris-sn

Thanks for the reply. Here's what I did:

    selected_devices.each do |device|
      n = Rapns::Apns::Notification.new
      n.app = Rapns::Apns::App.first
      n.device_token = device
      n.alert = notification.alert
      n.sound = 'default'
      n.shop_id = id
      n.save!
    end unless selected_devices.blank?

What should I look out for?

@ileitch
Owner
ileitch commented Jan 3, 2014

do a SELECT DISTINCT type FROM rapns_notifications, what do you get?

@maricris-sn

As I was fixing an app with an old rapns version, I revamped the code a bit. I removed old references and created new tables. This solved my problem. Also, I found that using the gem instead of referencing the git repo was helpful.

Thanks for the assistance!

@maricris-sn maricris-sn closed this Jan 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.