Skip to content
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

"reachabliity" - detecting if the device has network access - does not appear to work. #45

Open
biblicabeebli opened this issue Feb 14, 2024 · 6 comments
Assignees
Labels

Comments

@biblicabeebli
Copy link
Member

biblicabeebli commented Feb 14, 2024

If I enable airplane mode while testing (I was testing uploads) it still tries to upload.

    let reachable = studySettings.uploadOverCellular ? 
        self.appDelegate.reachability!.isReachable : self.appDelegate.reachability!.isReachableViaWiFi

    // other stuff

    // logic for running uploads code
    if now > nextUpload || (reachable && currentStudy.missedUploadCheck) {
        // This (missedUploadCheck?) will be saved because setNextUpload saves the study
        currentStudy.missedUploadCheck = !reachable // if not reachable we missed the upload check
        self.setNextUploadTime()
        if reachable {
            self.upload()
        }
    }
@biblicabeebli
Copy link
Member Author

@biblicabeebli
Copy link
Member Author

WOW this has become difficult:
https://stackoverflow.com/questions/30743408/check-for-internet-connection-with-swift?page=1&tab=scoredesc#tab-top

Old behavior always returned connected on wifi.
Added app entitlement that changed to completely block this back in ios 13.
Old Reachability.swift appears to be broken, the stack overflow post has a huge comment thread on problems with the top solution.

Alamofire seems to have something very similar built in but it has similar bugs, probably because we are on an old version.

@biblicabeebli
Copy link
Member Author

I have had to reimplement Reachability.

Reachability is a data stream that indicates what internet mode the device is in, e.g. wifi, cellular, or unreachable.
The library used was last updated for iOS 10 and cannot be made compatible again.

Reachability and probably upload-over-cellular was non-functional on all iOS versions since September 13, 2016.

Cool. Great. Fun.

For technical reasons determining "unreachable" is very, very difficult to do cleanly. The reachability data stream now only says "wifi" or "cellular", with "cellular" potentially meaning no connection. Restoring "unreachable" is potentially feasible, but requires the app do an extra network operation quite frequently.

The upload-over-cellular study setting has been fixed.

@biblicabeebli
Copy link
Member Author

pushing to build 2024.19

@biblicabeebli
Copy link
Member Author

@hydawo I expect someone somewhere will want to know about this kerfuffle.

@biblicabeebli
Copy link
Member Author

This issue is not of critical importance, if anyone wants this data stream upgraded/fixed they can comment on this thread, we will keep this thread open.

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

No branches or pull requests

2 participants