问题
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