Rails FCM引发ArgumentError

时间:2018-10-31 00:17:41

标签: ruby-on-rails firebase firebase-cloud-messaging

我正在将fcm gem用于我的Firebase推送通知。尝试向特定用户注册设备时,我不断收到ArgumentError: wrong number of arguments (given 1, expected 4)。它在这条线上跳了起来:

response = $firebase.add(key_name: self.user_id.to_s, project_id: ENV['FIREBASE_PROJECT_ID'], notification_key: self.user_id.to_s, registration_ids: [self.token])

在这里注册我的FCM客户:

$firebase = FCM.new(ENV['FIREBASE_KEY'])

有什么建议吗?

修改

Stacktrace:

  

ArgumentError:参数数量错误(给定1,预期为4)       从/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/fcm-0.0.2/lib/fcm.rb:71:in add_registration_ids' from (irb):5 from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/console.rb:65:in开始       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/console_helper.rb:9:in {{1} }安慰'       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:49:in {{1} }'       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in start' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:78:in中在要求中       从/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:259:in run_command!' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in中'       来自/ Users / ediewoelfle / Developer / ancient-bastion / bin / rails:9:in require' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in load'       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in load_dependency' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in load_dependency '       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:在<top (required)>' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in中调用'       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/command_wrapper.rb:38:in block in load' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:259:in中服务中”       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:171:在load' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/commands/rails.rb:6:in中'       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:141:in call' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:201:in '       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in fork' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:171:in'       来自/Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in block in run' from /Users/ediewoelfle/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in require'       来自-e:1:in''

0 个答案:

没有答案