When finding out joyous tidings or upon hearing good news from a reliable source, one says a Bracha.
If it only affects oneself, then one says שֶׁהֶחֱיָנוּ; "... who has kept us alive, sustained us and permitted us to reach this occasion."
If it affects a group of people then one says הַטּוֹב וְהַמֵּטִיב; "..Who is Good, and bestows good."
If one cannot say the Bracha right away - due to an unclean location or hands - then one can say it later, as long as one still feels the joy.
Even if the joyful event will probably cause one trouble at a later date, one still says the Bracha.
Source: Kitzur Shulchan Aruch 59:1,3
Monday, 5 Tammuz 5776