Display Web Push Notification with long title/body/text on Chrome/Firefox without having it truncated

笑着哭i 提交于 2020-04-30 10:12:47

问题


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:

truncated text notification example

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.


回答1:


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.



来源:https://stackoverflow.com/questions/46043348/display-web-push-notification-with-long-title-body-text-on-chrome-firefox-withou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!