Method №1 (Official)
To fix this you need to perform 4 steps:1) Turn "Adaptive Battery" on.
Settings → Battery → Adaptive Battery → On
2) Specify applications that do not need to be optimized.
Open "Settings → App & notifications → Advanced → Special app access → Battery optimization → All apps" and then open needed apps (e.g. WhatsApp or Viber) and choose "Don't optimize".
3) Check app's notifictions settings.
Open "Settings → App & notifications → <Needed application> → Notifications" and make sure that all necessary options are turned on.
4) Reboot the phone.