Fixed enableForegroundDispatch bug by ensuring application is active.