Currently I'm building an iOS app using tdlib, the first problem was, when user minimizes the app sockets are closed down, so td::Client crashes. Now I destruct client object every time when app goes background and recreate when it goes foreground.
And now there's another problem, previously saved file_ids are no longer available for download. Every downloadFile request fails with "400 - Invalid file id".
How do one save file ids for later download?
There should be no crash if sockets are closed, it is an ordinary situation. What exactly happens?
Yes, file.ids aren't persistent. If you want to have file downloads persistent across application restarts, currently you need to save file.remote.id and use getRemoteFile to get the file after restart. file_type in getRemoteFile call can be specified as NULL in that case.
Thanks for reply.
If sockets are closed, there's this error
[1522774473.039885044][Fd.cpp:362][!Session:2:download_small] [PosixError : Socket is not connected : 57 : Read from fd 31 has failed]"

Thanks, we will fix it in the next release. You can fix it yourself, moving line https://github.com/tdlib/td/blob/cfe4d9bdcee9305632eb228a46a95407d05b5c7a/tdutils/td/utils/port/Fd.cpp#L361
after line
https://github.com/tdlib/td/blob/cfe4d9bdcee9305632eb228a46a95407d05b5c7a/tdutils/td/utils/port/Fd.cpp#L366
Yes, try what offers @levlam. It is interesting to look at the result
Thank you, I've recompiled tdlib using the patch you suggested, and everything works even without reconstructing td::Client object.
Also, I'm using remote file ids now, and everything works as expected.
"PosixError : Socket is not connected" error handling is fixed in 1.3.0. There is no crash anymore.
Most helpful comment
Thanks, we will fix it in the next release. You can fix it yourself, moving line https://github.com/tdlib/td/blob/cfe4d9bdcee9305632eb228a46a95407d05b5c7a/tdutils/td/utils/port/Fd.cpp#L361
after line
https://github.com/tdlib/td/blob/cfe4d9bdcee9305632eb228a46a95407d05b5c7a/tdutils/td/utils/port/Fd.cpp#L366