openfoodfacts/openfoodfacts-ios

Offline scans are not logged to history

teolemon opened this issue · 4 comments

Offline scans are not logged to history

Hello! I am interested in working on this issue. I am new to open source but I have two years of iOS development experience and I have published a native iOS to the App Store. May we discuss a design to solve this one?

Here is what I've found so far, please let me know if I'm on the right track:

I tested the offline scan by setting my device to airplane mode and scanning a food product.
This forces the error callback (line 442) to be called in ScannerViewController inside getProduct(barcode: ...)
The next line checks isOffline(errorCode:) and if true, call handleGetProductSuccess(barcode: ...) in order to //Assume product does not exist and store locally for later upload

For me, the error code passed is -1004 "Could not connect to the server."
Because this does not match NSURLErrorNotConnectedToInternet || NSURLErrorTimedOut isOffline isOffline(errorCode:) returns FALSE even though I am offline in airplane mode.

I get the same errorCode (-1004) when I turn off WiFi.
Would including this NSURLErrorDomain Code=-1004 in isOffline(errorCode:) be the best way to fix this?

Sounds logical to me

The issue is still here on latest build