TN2302 Passbook FAQ is misleading with respect to UIWebView

Originator:david.anderson
Number:rdar://16064972 Date Originated:13-Feb-2014
Status:Open Resolved:
Product:Documentation Product Version:
Classification: Reproducible:
 
Summary:
TN2302 with respect to adding passes to Passbook from a UIWebView in an app indicates that unspecified UIWebView delegate methods can be used to identify (based on MIME type) when the UIWebView has loaded a passbook file. UIWebView does not have any publicly available delegate methods that can allow inspection of MIME type.

---- Quote ----

I'm using a UIWebView in my app and it does not automatically support adding passes to Passbook. What should I do?
UIWebViews do not automatically support adding passes to Passbook. To add passes using a UIWebView, implement the appropriate UIWebViewDelegate methods to identify when the view loads data with a MIME type of application/vnd.apple.pkpass. Download the data for the request and instantiate a PKPass object with that data. Use the PKAddPassesViewController class to present the pass to the user, or if the pass is already in the user's Passbook Library, use the -[PKPassLibrary replacePassWithPass:] method to update it.

---- End Quote ----

"implement the appropriate UIWebViewDelegate methods" is non-specific and misleading.  The only available UIWebViewDelegate methods are as follows.

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
- (void)webViewDidFinishLoad:(UIWebView *)webView
- (void)webViewDidStartLoad:(UIWebView *)webView
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error

None of these methods, or the UIWebView instance available in them, provides access to the NSURLResponse (and therefore its -MIMEType) that could be used to detect application/vnd.apple.pkpass

It is therefore not possible to detect an NSURLResponse MIMEType without leveraging an NSURLProtocol subclass and an independent NSURLConnection in order to have access to the resulting NSURLResponse MIMEType.

Steps to Reproduce:
Attempt to access the NSURLResponse MIMEType from a UIWebView instance any of the above UIWebViewDelegate methods.


Expected Results:
The documentation should be more specific about the specific "appropriate UIWebViewDelegate methods" that should be leveraged or otherwise more accurate recommendations should take their place.


Actual Results:
Following the documentation there is no mechanism for detecting the MIMEtype of passbook data loaded by the UIWebView.


Version:

TN2302
Passbook FAQ

https://developer.apple.com/library/ios/technotes/tn2302/_index.html

Notes:
As described above, a complicated mechanism using NSURLProtocol can be used to detect a request for a .pkpass file, create a separate NSURLConnection and examine the NSURLResponse from that connection for the appropriate MIMEtype.

Perhaps the author of the documentation was referencing private UIWebViewDelegate methods, such as those listed here: https://github.com/nst/iOS-Runtime-Headers/blob/d576a9cc197412e81aa87624b755e59b4f00e3cd/Frameworks/UIKit.framework/UIWebViewWebViewDelegate.h


Configuration:


Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!