3 Replies
      Latest reply: Jan 19, 2017 12:58 AM by eskimo RSS
      cfromns Level 1 Level 1 (0 points)

        Is it necessary to monitor reachability for on-demand resources?  If so, what host address should be used?  Thank you.

        • Re: SCNetworkReachability / On-Demand Resources
          eskimo Apple Staff Apple Staff (6,270 points)

          Is it necessary to monitor reachability for on-demand resources?

          No.

          I’m curious what prompted this question.  How are you using reachability in other contexts?

          In my experience reachability is one of the most overused API on our system.  The API can be useful in some limited circumstances, but most folks end up using it for the wrong reasons, and that causes more problems than it solves.

          Share and Enjoy

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

            • Re: SCNetworkReachability / On-Demand Resources
              cfromns Level 1 Level 1 (0 points)

              My interest in reachability is based upon two contexts within my application:

               

              1.  Determine if the server hosting the website associated with the application is available.

              2.  I anticipated that a likely error associated with beginAccessingResources would be NSURLErrorNotConnectedToInternet.

               

              Thank you for your helpful reply.

               

              Please allow me to refine my interest in reachability:   Apple's On-Demand Resources Guide / Debugging On-Demand Resources / Networking Issues refers to the Reachability sample code and indicates this code can isolate common networking problems.  The ReadMe.md in Reachability / Using the Sample mentions that www.apple.com is the default host and that this address can be changed.  I wondered if it might be changed to an address associated with on-demand resources.

               

              Perhaps I have misunderstood the documentation, but given the above, I'm under the impression that the Reachability code should be included in my application to identify networking errors for presentation to a user.

                • Re: SCNetworkReachability / On-Demand Resources
                  eskimo Apple Staff Apple Staff (6,270 points)

                  OK, just so we’re clear on the context, here’s the quote from the On-Demand Resources Guide:

                  Debugging networking issues is made easier with the Reachability sample code. It can check for network connectivity and the type of connection, and it can determine whether a specific host is reachable. You can use the information to isolate common networking problems. For example, if the host is reachable but the resources cannot be downloaded, either the app has the wrong URL for resources, or the host configuration has changed.

                  Other common network issues include the following:

                  • The device is not connected to the network.

                  • The device is connected to cellular, and the user has turned off data access for the app.

                  • There is connectivity, but the server is not available.

                  • The app is using self-hosted on-demand resources, and the URL for the content has changed.

                  Honestly, I have no idea what the author of that doc was angling at here.  Are they recommending that you do this during development?  Or for in-the-field diagnosis of problems?  I read it as the former but you’ve interpreted it as the latter.

                  Regardless, I want to come back to something you wrote:

                  2. I anticipated that a likely error associated with beginAccessingResources would be NSURLErrorNotConnectedToInternet.

                  It sounds like you haven’t actually tested this.  If so, my recommendation is that you try it and see what errors you actually get.  This will inform how you should proceed with the error handling.

                  Share and Enjoy

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