Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Notifications did not work as expected. #26

Open
danilamaster opened this issue Jun 12, 2020 · 1 comment
Open

Notifications did not work as expected. #26

danilamaster opened this issue Jun 12, 2020 · 1 comment

Comments

@danilamaster
Copy link

Little experiment on XCODE 11.5

Add Reach.swift to project

Add code

NotificationCenter.default.addObserver(self, selector: #selector(ViewController.networkStatusChanged(_:)), name: Notification.Name(rawValue: ReachabilityStatusChangedNotification), object: nil)
		Reach().monitorReachabilityChanges()

to viewDidLoad() of ViewController


Turn Network Off unplugging net cable and switch off Wi-Fi connection on Mac

Build and start project in Simulator

We get string "Offline" on output. Everything is fine right now.

Switch internet connection On connecting to WiFi. Run some net activity in project. Download some data successfully. Nothing happen in NotificationCenter about ReachabilityStatusChangedNotification.


Another scenario with same code.

Turn Network On unplugging net cable but switch Wi-Fi connection On

Build and start project in Simulator

We get string "Online" on output. Everything is fine right now.
Switch Wi-Fi off.
We get string "Offline" on output. Everything is perfect! But
Reconnect Wi-Fi. Run some net activity in project. Download some data successfully.
Ooops.
Nothing happen in NotificationCenter about ReachabilityStatusChangedNotification again.

@danilamaster
Copy link
Author

On real device all works fine after turning router on/off.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant