opened
paulofierro
username_0
But when offline this is not the case — the block is not called  at all.

This is my use case:

Our app adds lots of events in short time spans and calling `uploadWithFinishedBlock:` can add duplicate events as events that are uploading are only cleared from the pending queue when the upload completes. Therefore we internally keep track of whether an upload is in progress or not, and clear this flag when the block we pass in is called.

As this the block isn't called while offline this means that our app will never upload new events. For now we've added a work around where we don't call `uploadWithFinishedBlock:` while offline.
Completion block not called when offline
issue
created
heitortsergent
username_1
Hey @username_0, thanks for reporting this! I had not tested for that use case, sorry for the wrong information in the docs. So it seems we have two things to fix:

1. Duplicate upload when calling `uploadWithFinishedBlock` multiple times in a row (before an event finishes uploading and gets deleted from sqlite)
2. Call `uploadWithFinishedBlock` completion block regardless of success/fail like stated in docs

I'll open another issue for the first one, and keep you updated on the second one here!
comment
created
paulofierro
username_0
Thanks @username_1! 

I found one more case where this would happen — if `prepareJSONData:andEventIds` fails, then `data.length = 0` at https://github.com/keenlabs/KeenClient-iOS/blob/master/KeenClient/KeenClient.m#L841 which means the completion block isn't called.

Its very rare but we have seen it happen.
comment
created
heitortsergent
username_1
That makes sense. Thanks for being so thorough @username_0! 👍 

I'll work on a fix for this issue this week.
comment
closed
heitortsergent
username_1
issue