This article explains how to use the Delete Unused Apps feature on iPhones running iOS 11 and later and how it can help you avoid the Storage Almost Full notification.
How to Delete Unused Apps on Your Apple iPhone
iPhone recommendations ensure that you always have enough space for your next download. If you don’t want to chew up every app’s storage and want to free up space, Offload Unused Apps can work in the background to reclaim space while backing up app data.
Select App Store > Remove Unused Apps.
Turn on the Offload unused apps switch.