Question

I've setup a system where a customer can scan a QR code that links to a registration webpage. After entering some information, the customer receives a Passbook coupon.

There is a problem - Passbook .pkpass files need to be sent to a browser with the right MIME type enabled :

application/vnd.apple.pkpass pkpass;

Safari for iOS is already configured to accept this MIME type. However, many free QR code scanning Apps use an in-app browser that does not support this MIME type.

How do I filter the http_user_agent string to check if a customer is browsing from Safari or from an in-app browser?

Thanks if you can help ..

p.s. I know that Passbook for iOS7 includes a compatible QR code scanner - I need to manage users with older versions of iOS (as well as situations where I want to link to a registration page instead of directly to a Passbook file)

Was it helpful?

Solution

The simplest choice would be to whitelist the iOS iPhone and iPad user agents for Safari 6 and above, Chrome 23 and above. The downside is that you'll miss apps that have implemented Passbook support into their UIWebView implementation.

A blanket ban on the UIWebView UA string would not be effective because:

  1. The app author is free to change the UIWebView user agent string
  2. You would block access for apps that have implemented Passbook support

The Facebook app is a good example of one that has both changed the UA string and implemented Passbook support. The Twitter app has changed the UA string but has not implemented Passbook support.

So option 2 could be to create a blacklist of apps known not to have implemented support. Scanning this QR will reveal the user agent string of the browser, which may help. The key is using a suitable regex to account for variations in the OS and app version, but avoid false positives.

enter image description here

A third option would be be to use Javascript to display a prominent message that instructs the user to open the link in Safari if they the app browser stops responding and then redirect to the .pkpass bundle.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top