openfoodfacts-ios icon indicating copy to clipboard operation
openfoodfacts-ios copied to clipboard

Offline scans are not logged to history

Open teolemon opened this issue 5 years ago • 4 comments

Offline scans are not logged to history

teolemon avatar Mar 08 '19 11:03 teolemon

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?

jncosideout avatar Aug 08 '20 23:08 jncosideout

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?

jncosideout avatar Aug 09 '20 21:08 jncosideout

Sounds logical to me

philippeauriach avatar Aug 10 '20 07:08 philippeauriach

The issue is still here on latest build

teolemon avatar Dec 06 '20 14:12 teolemon