Cache a single webpage for use when offline in Xco

2019-07-19 00:12发布

I have a UIWEBVIEW that connects to a "login.php?email=a@b.com&password=aaa"

Login .php uses these details to login to an external website and fetch and display its contents using CURL.

I have got my login.php to store the webpage into a folder "/cache/a@b.com.html" on my webserver.

I now need to find a way to tell Xcode / UI webview

If there is an internet connection: -Visit login.php -Download latest /cache/a@b.com.html and store local.

If there isnt an internet connection: -Load local 'a@b.com.html' file.

I hope you understand,

I have looked at some systems out there such as: http://robnapier.net/blog/offline-uiwebview-nsurlprotocol-588

But that stores the file that your UIWEBVIEW visits which in my case is 'login.php'.

Thanks,

Jack.

1条回答
一纸荒年 Trace。
2楼-- · 2019-07-19 00:46

I never managed to complete the task this way, by did make use of the RNCachingURLProtocol at https://github.com/rnapier/RNCachingURLProtocol/blob/master/RNCachingURLProtocol.h

查看更多
登录 后发表回答