与火力轨iOS和Android的通知推送红宝石

问题描述 投票:0回答:1

你好,我正在寻找一个红宝石与火力轨推送通知的瑰宝,我其实是很新的通知,我感谢所有帮助移动设备。我完成一个项目,我只需要在后端。

我想,例如,每一个服务由客户端移动应用内登记的时候,我都会生成一个推送通知它说:“新的服务已经产生”,而所有员工都可以看到它

android ios ruby-on-rails push-notification
1个回答
0
投票

嘿,你可以使用我一直在使用这一段时间的RPUSH宝石它真的很容易处理,非常说明性文件,从来没有遇到任何问题与它。我们可以通过单一的宝石easliy处理IOS / Android的通知。

首先,你需要安装RPUSH并运行此命令捆绑EXEC RPUSH的init

现在写下一个任务添加火力API密钥

app = Rpush::Gcm::App.new
app.name = "android_app"
app.auth_key = "..."
app.connections = 1
app.save!

当您需要发送通知,你需要用这种方法来推通知,并在通知表

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
you can use!
n.notification = { body: 'great match!',
                   title: 'Portugal vs. Denmark',
                   icon: 'myicons'
                 }
n.save!

在应用控制器添加此,并在项目随处可见调用此方法。

© www.soinside.com 2019 - 2024. All rights reserved.