简体   繁体   English

在Rails应用中使用Firebase消息传递

[英]Using firebase messaging in a Rails App

I want to recieve notifications in my rails app and show them to the user (which accept to get notification) 我想在我的Rails应用程序中接收通知并将其显示给用户(接受通知即可)

I setup the client with 我用

firebase.initializeApp(config);
const messaging = firebase.messaging();

Then 然后

messaging.requestPermission().then(..)

I added "public/firebase-messaging-sw.js" and "public/manifest.json" 我添加了“ public / firebase-messaging-sw.js”和“ public / manifest.json”

I can't get the message using "onMessage" but I want to get them in background 我无法使用“ onMessage”获取消息,但我想在后台获取它们

在此处输入图片说明

If your page is NOT open and NOT focused the SDK will send the background to the service worker in the Background. 如果您的页面未打开且未聚焦,SDK将在后台将背景发送给服务人员。

If you open a window to a new website and then send a message do you see the notification? 如果打开新网站的窗口然后发送消息,您是否看到通知?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM