Added online and offline events (needs testing on device)