-
Notifications
You must be signed in to change notification settings - Fork 397
Use NWPathMonitor for iOS/macOS #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Use NWPathMonitor for iOS/macOS #497
Conversation
If NWPathMonitor was only introduced in iOS12/macOS10.14 that's problematic, this is a module used widely so rather than go past the current react-native minimum (which is 11) this module really should maintain compatibility with the iOS/macOS versions supported by the most recent couple of versions. It was 10 until quite recently (react-native 0.65 was released just a short while ago with that change to 11) 12 shouldn't be the minimum for quite a while Similarly, react-native-macos runs on macOS 10.13 so using these symbols exclusively is problematic at this point |
Separately - the compile error reminded me of this thebergamo/react-native-fbsdk-next#97 - I wonder if a separate commit (or separate PR?) with the needed change would do the trick. That said, I haven't had any problems compiling netinfo with any version of Xcode up to and including the last Xcode 13 beta - I had not checked the RC and it's released proper as 13 now, but I assume it will still work. I'm surprised to see a compile error. |
@mikehardy thanks for reviewing my PR! I really appreciate it! Regarding compile errors – I compiled the example, and since errors are in React-Core, probably that's just some older version of ReactNative or something like that. I can dig into this. Regarding deployment target: We can go with one of two options here:
Please let me know your thoughts |
I am actually all for new (better) API uses, and if it requires an IFDEF for new APIs, with the "old" style marked clearly as "delete when iOS deployment target is greater than XYZ" and the APIs themselves (in the README) are also marked clearly as "uses XYZ strategy for ios < NN / macOS < NN, uses ABC strategy for ios >= YY / macOS >= YY". That puts the information for necessary testing out there, marks it for sunset, and lets the newer/better APIs shine I can say that I just compiled the module itself using Xcode 13 and it's fine, and I know it was fine on Xcode 12.5 etc so that must be some sort of error local to your environment or as you mention something about the react-native version in the example. The example is probably pretty stale so it's easy to guess that is the source... |
(actually, rather than ifdef since those symbols should be available in all supported Xcode versions, maybe an |
Happy to merge this as long as it has some backwards-compatibility for the old style, iOS 12 is still not even the react-native default so that's a non-starter for a while unfortunately. Probably 2 years really. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the ability to merge + release here now but needs changes as noted
Overview
The network type for ethernet was reported incorrectly on macOS.
Since there's a new API NWPathMonitor (introduced in iOS 12/macOS 10.14) to detect network connectivity changes, I rewrote ios network state watching using this API.
Test Plan
I'm blocked on testing on the example project because the build is failing on the latest Xcode (likely due to an outdated RN version). Here's what I get on Xcode 12.5.1:

Demo from our project that's using a forked lib:
https://user-images.githubusercontent.com/1094629/134097094-ed289262-c1e6-4cba-b979-6e290d1ff0d8.mov
Test Case 1:
Test Case 2: