Notification Priority Levels

I want to notify users and am wondering which option to choose.

The first option shows an icon with a flag indicating that there are notifications.

For example:

Notification alert in top bar with open notification tray



The second one shows popups like in this picture :

"toast" style popup notifications

Under which circumstances is one better than the other?

As a side note What the 2 types are called?