Detect downloads in UIWebView

Discussion in 'iOS Programming' started by nomar383, May 14, 2010.

  1. nomar383 macrumors 65816

    nomar383

    Joined:
    Jan 29, 2008
    Location:
    Rexburg, ID
    #1
    Safari on the iPad is able to detect downloads and give you a warning if it doesn't understand how to handle them. How do I detect downloads in a similar manner for my iPad app?

    I've been searching google for hours with no luck :(

    My app needs to detect downloads that are generated and returned through scripts (php, javascript, etc) and then handle them. When I click a link in my UIWebView that functions in this manner, I get this error:
    Error Domain=WebKitErrorDomain Code=102 UserInfo=0x514af70 "Frame load interrupted"

    In Safari, I get a warning (via a UIAlert). So, I'm assuming Safari has some way to handle this and KNOWS that it's a download. Ideas?
     
  2. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    Look in the UIWebview documentation for the webView:shouldStartLoadWithRequest:navigationType: method. You can inspect every URL before any network load starts, and reject the ones you don't want.
     
  3. nomar383 thread starter macrumors 65816

    nomar383

    Joined:
    Jan 29, 2008
    Location:
    Rexburg, ID
    #3
    I tried using that method already, and I'm checking the "request" for what the URL is. The URLs that are being returned don't seem useful (no extension of any kind). So, I am unable to use something like NSData to download from the URL.
     

Share This Page