How to disable pop-up / preview (heads up) message notifications for Samsung Galaxy S7, S8 and S8+

To disable heads-up notifications, install Android SDK and issue the following command in command line (all in one line):
adb shell settings put global heads_up_notifications_enabled 0

To simply view current settings before or after changes, use:
adb shell settings get global heads_up_notifications_enabled

More ways on how to disable these settings (if not available via user interface) is located at xda-developers site.

P.S. This works on Samsung Galaxy S7 edge with Android 7.0 and Galaxy S8+ Android 7.0.