I've found that I need some different behaviors based on whether the user is visiting my VisualForce page via the Salesforce1 native app (iOS or Android) or is using a mobile browser on the /one/one.app URL. I've seen answers for testing sforce.one
to determine if the user is on Salesforce1, but this doesn't help for native vs. mobile web.
This post mentioned testing for SalesforceTouchContainer
in the user agent string. I'm not actually seeing that work, but the following JavaScript does seem to work properly for me on both Android and iOS:
<script>
var isSalesforceNative = (window.navigator.userAgent.toLowerCase().indexOf('salesforce1') != -1);
</script>
It works, but it feels hacky to me. Does anyone have a better suggestion on how to do this, or is user agent sniffing really the only way?