sheagcraig / yo

Send Notification Center messages from the command line
Apache License 2.0
384 stars 44 forks source link

Support Multi Line text #42

Closed frakman1 closed 5 years ago

frakman1 commented 5 years ago

When using a long message for a title, subtitle or informative text, then text is always truncated. It would be nice if it would split it across multiple lines the way that a regular system notification does.

$yo_scheduler -t "This is a really long message that I want to see on two line"

image

sheagcraig commented 5 years ago

Hi @frakman1. So the parameter type for the title is a Swift string, which doesn't include styling information. If you try to put newlines in, e.g. /usr/local/bin/yo_scheduler -t "multiline \n string", it just prints it literally.

Eventually we'll have to move to UNUserNotificationCenter, and if you dig down through the 5 steps for generating a notification, it still only takes a string: https://developer.apple.com/documentation/usernotifications/unnotificationcontent https://developer.apple.com/documentation/usernotifications/unnotificationcontent/1649855-title

So this is really a design limitation that Apple imposes on us. You need to keep the title short enough to fit in the space allotted. You can flow additional text into the subtitle and body. BUT, you need to test these, because each additional element that you add takes up the space that you have, so even if a title string fits by itself, it may not fit when you add in a subtitle! The alternative option is to have the title be short and sweet, and the action button would then send the user to a webpage (which could be locally stored!) which has much deeper information about the message.

If you find any examples of how this could be done despite these limitations, please let me know!