Determining Maximum Height for Notification Content in Notification Content Extensions

I am working with Notification Content Extensions and need to ensure that the content fits within the notification without scrolling. I want to know if there is any API that can provide the maximum available height for the notification content area. My goal is to avoid making the content scrollable inside the notification. Is there a way to dynamically retrieve the height of the notification space, so I can properly adjust the content layout and ensure it fits perfectly without requiring the user to scroll?

While there isn't a direct API to query the maximum available height for a notification content extension, you can use a workaround to dynamically adjust the content layout and avoid scrolling

preferredContentSize Property: Override the preferredContentSize property of UIViewController to adjust the size of your view controller.

let size = view.bounds.size
preferredContentSize = CGSize(width: size.width, height: size.height / 4.0)

You can modify the height of the notification by changing the division factor (4.0 in this example)

How did you arrive at the number 4, as size.height returns a value greater than the available height for the content extension?

Determining Maximum Height for Notification Content in Notification Content Extensions
 
 
Q