A guava tree that produces well and then drops in production usually has a nutrition problem, so the first thing is to check if the plant is getting potassium and phosphorus properly. These two elements are essential for flowering and fruiting, and if the soil is depleted after two years of heavy production, it may have exhausted its reserves. Try fertilizing with a fertilizer more focused on phosphorus and potassium (like an NPK 4-14-8, for example) and see if flowering improves this year or in the next cycle.
Another common issue is excess nitrogen, which makes the plant too vegetative, only growing branches and leaves without flowers. If you're watering too much or using a fertilizer too high in nitrogen, that could be it. It's also worth checking if it doesn't have invisible pests or some micronutrient deficiency like zinc or boron, which affect flowering. Do a good cleanup of the dead branches, make sure it's really getting sun all day long (without shade from a neighboring tree that's grown), and then adjust the fertilization. Guava trees are hardy, so they're pretty able to bounce back quickly with the right adjustments.