For all version of Android SDK, by default, when a notification comes in and the user taps the notification, the app displays an alert, no matter if the app is in the foreground or not.
In order to customize this, please create your own custom notification service extension.
To be more specific, it will be necessary to override a boolean method onMessageReceived(PushMessage message) with a simple 'if' statement which will check whether the app is in the foreground or not.
It can be done with an isAppOnForeground() method of the same NotificationServiceExtension class. In case if this check will return 'true', do not display a push. That's it!