本文介绍了在Chrome/Firefox上显示带有长标题/正文/文本的Web推送通知,而不会被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了Google的Web推送通知教程( https ://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/),并将服务人员添加到我的网络应用中.但是,我注意到通知文本在大多数情况下会被截断,例如以下示例:

I completed Google's tutorial for web push notifications (https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/) and added a service worker to my web app. However, I noticed the notification text is truncated on most cases, like in the following example:

文本截断的通知示例

我想在Chrome/Firefox上显示网页推送通知,其正文较长(2-3行),标题可能较长(2-3行).有官方支持吗?是否可以选择不截断通知文本并显示所有内容?或者如何在截断之前显示一定数量的行?谢谢.

I would like to display a web push notification on Chrome/Firefox with a relatively long body (2-3 lines) and possibly a long title (2-3 lines). Is there official support for this? Is there an option not to truncate the notification text and display all of it? Or how to display a certain number of lines before it gets truncated? Thank you.

推荐答案

否,这是不可能的.浏览器/操作系统/上下文的任意组合都可以酌情截断截短长度的通知.尚无任何官方规范.但是,如果转到操作系统通知中心,通常可以读取整个通知(而其他内容上显示的通知通常会被截断).如果您的文字简短,那么被截断的可能性就较小:例如在Pushpad中,我们将标题的长度限制为30个字符.

No, it's not possible. Any combination of browser / OS / context can discretionally truncate the notification at a different length. There isn't any official specification about it. However, if you go to the OS notification center, you can usually read the whole notification (while the notification displayed on the other content is usually truncated).If you keep your text short then is less likely that it gets truncated: for example at Pushpad we constrain the length of the title to 30 characters.

这篇关于在Chrome/Firefox上显示带有长标题/正文/文本的Web推送通知,而不会被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 12:44