在rpush中缺少GCM的通知属性

时间:2016-02-11 00:41:51

标签: android ruby-on-rails google-cloud-messaging

rpush gem for android通知的文档中,它说:

n = Rpush::Gcm::Notification.new
n.app = Rpush::Gcm::App.find_by_name("android_app")
n.registration_ids = ["..."]
n.data = { message: "hi mom!" }
n.priority = 'high'        # Optional, can be either 'normal' or 'high'
n.content_available = true # Optional
# Optional notification payload. See the reference below for more keys you can use!
n.notification = { body: 'great match!',
                   title: 'Portugal vs. Denmark',
                   icon: 'myicon'
                 }
n.save!

当我运行它时,发生了错误:

NoMethodError:未定义的方法`notification ='

我检查了模型,发现它没有包含notification属性

=> #<Rpush::Client::ActiveRecord::Gcm::Notification:0x007fb90f610790
 id: nil,
 badge: nil,
 device_token: nil,
 sound: "default",
 alert: nil,
 data: nil,
 expiry: 86400,
 delivered: false,
 delivered_at: nil,
 failed: false,
 failed_at: nil,
 error_code: nil,
 error_description: nil,
 deliver_after: nil,
 created_at: nil,
 updated_at: nil,
 alert_is_json: false,
 type: "Rpush::Client::ActiveRecord::Gcm::Notification",
 collapse_key: nil,
 delay_while_idle: false,
 registration_ids: nil,
 app_id: nil,
 retries: 0,
 uri: nil,
 fail_after: nil,
 processing: false,
 priority: nil,
 url_args: nil,
 category: nil,
 content_available: false>

它出了什么问题?

1 个答案:

答案 0 :(得分:0)

rpush版本更新为2.7.0,它只是在2天前升级到此版本。