3 Replies
      Latest reply: Dec 26, 2016 1:47 PM by eskimo RSS
      Cryp Level 1 Level 1 (0 points)

        Hello,

         

        I'm trying to migrate to WKWebView.

        Currenly my project uses UIWebView.

        The problem is that all my resources are encrypted, by utilizing the URLProtocol i can decrypt all the requested resources on the fly.

         

        As the WKWebView is not using URLProtocol, i still need to substitute the requested resources with decrypted ones.

        Is there any way to handle this for WKWebView?

         

        Thanks in advance.

        • Re: WKWebView question
          eskimo Apple Staff Apple Staff (7,960 points)

          Is there any way to handle this for WKWebView?

          Not easily.

          What sort of resources are you talking about?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: WKWebView question
              Kazuka Level 1 Level 1 (0 points)

              Hello,

              It cloud be a JS/PNG/JPEG/HTML files as well as some custom fonts, css etc..
              My app is some kind of a container, which downloads some html/js/images etc... files.
              I'm not controlling the content. Also, i have protection keys which are store in DB per each encrypted file.

              Some of these files are encrypted some of them not.

              Don't know the reason, this comes from the client request.
              So for UIWebView + URLProtocol it works perfect. Tried with WKWebView, but can't find a way to do the same as for UIWebView.

              Some years ago, i'm using NSURLCache instead of NSURLProcol, but this stops working for "FILE" url scheme after some iOS version update.

              Not sure, if NSURLCache can be used here.

               

              Thanks in advance.

                • Re: WKWebView question
                  eskimo Apple Staff Apple Staff (7,960 points)

                  It cloud be a JS/PNG/JPEG/HTML files as well as some custom fonts, css etc … I'm not controlling the content.

                  OK.  Alas, there’s no way to make this work for WKWebView.  The reason this works for UIWebView is that UIWebView runs entirely within your process and does its network requests with NSURLSession.  NSURLSession consults NSURLProtocol subclasses, so you can insert yourself into the loading process.

                  In contrast, the bulk of WKWebView, and specifically the code making its network requests, runs outside of your process, and thus does not see your NSURLProtocol subclass.

                  As things currently stand you’ll have to stick with UIWebView.  If you'd like to see WKWebView support this sort of thing in the future, I encourage you to file an enhancement request describing your requirements. Please post your bug number, just for the record.

                  Not sure, if NSURLCache can be used here.

                  NSURLCache will definitely not help here; like NSURLProtocol, it’s only consulted by network requests run in your process.

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"