Search code examples
iosswiftnetwork-programmingapp-storereachability

Is it safe to use 'com.apple.system.config.network_change' notification to detect network reachability changes?


Is it safe to use 'com.apple.system.config.network_change' notification to detect network reachability changes? Or is it considered to be a private API? For now my code looks like this:

CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
                                nil,
                                callback,
                                "com.apple.system.config.network_change" as CFString,
                                nil,
                                .deliverImmediately);

And then in callback I respond to the notification.

The problem is Reachability in iOS not always detects Wi-Fi switching. For instance, if we are switching from one Wi-Fi AP to the other that system already knows (because we have used it in the past) then it happens so fast that there's no 'Disconnected' event and I cannot track the actual switching moment. Solution above works but I am sure whether my app won't be rejected for publishing in the App Store.

Thanks!


Solution

  • That is considered to be a public API for now. For more details please see this thread:

    https://forums.developer.apple.com/message/334035#334035