在rpush中缺少GCM的通知属性(Missing notification attribute for GCM in rpush)

系统教程 行业动态 更新时间:2024-06-14 16:57:39
在rpush中缺少GCM的通知属性(Missing notification attribute for GCM in rpush)

在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>

它出什么问题了?

In the document for rpush gem for android notification, it says:

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!

When I run it, a error occurred:

NoMethodError: undefined method `notification='

I checked the model, and I found it didn't include notification attribute

=> #<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>

What's wrong with it?

最满意答案

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

Update the rpush version to 2.7.0, it just upgrade to this version 2 days ago.

更多推荐

nil,notification,false,Gcm,电脑培训,计算机培训,IT培训"/> <meta name="de

本文发布于:2023-04-13 12:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/dda80cca2748ae5e2e11dd72d2212ba7.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   通知   GCM   rpush   notification

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!