You can disable notifications from specific applications or contacts, or even all of them, using the Focus Mode toolkit. A few default settings, such Driving, Sleep, and Do Not Disturb, are each suitable for a certain activity. You can also create your own unique settings. And this feature will save you from all unwanted messages.
Source:- https://ityug247.com/notification-silenced-messages-on-iphone/