getObscurityFlags() and how do you actually use it?

Hi fellow devs, the sample code behavior of getObscurityFlags() seems to only work on simulator. Based on documentation getObscurityFlags() should be called at onUpdate() however if I do that it seems to break the simulator as well.

How do you actually implement it so that both real hardware and simulator behaves correctly?