Answer Network.Status on iOS from one long-lived path monitor - #3
Open
ngunyimacharia wants to merge 1 commit into
Open
ngunyimacharia wants to merge 1 commit into
ngunyimacharia wants to merge 1 commit into
Conversation
…ead of guessing offline on a slow first path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The iOS
Network.Statusstarts a newNWPathMonitoron every call, waits up to 2s for its first path, and cancels it. That has two costs:connected: false. If the first path is slow, a device on working wifi is told it is offline, and apps that gate writes on it refuse them.This change keeps one monitor alive for the life of the process and answers from its latest path. Only the first call can arrive before any path does, so only that call waits (0.5s). If nothing has arrived by then, it returns the usual shape plus an
errorkey, the same way the Android implementation already reports a failure, instead of claiming the device is offline.The response shape is unchanged for every existing field, so
$status->connectedstill works. The README documents theerrorcase.This long-lived observer has shipped in our app since its v0.7.0 release, as a patch on
nativephp/mobile(see NativePHP/mobile-air#507, closed in favour of this plugin). Theerrorfallback is the only new part.Not tested here: no Swift toolchain on the machine this PR came from, and the plugin's suite is PHP only.