Skip to content

Instantly share code, notes, and snippets.

@GiancarloGomez
Last active September 6, 2016 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GiancarloGomez/1ccb627fb0504b67022aeb1e4d7ab65d to your computer and use it in GitHub Desktop.
Save GiancarloGomez/1ccb627fb0504b67022aeb1e4d7ab65d to your computer and use it in GitHub Desktop.
An example Struct using the ColdFusion MobileDetect CFC : https://github.com/GiancarloGomez/ColdFusion-MobileDetect/
<cfscript>
session.agentCheck = {
version : MobileDetect.getVersion(),
checkedOn : now(),
isMobile : MobileDetect.isMobile(),
isTablet : MobileDetect.isTablet(),
isIpad : MobileDetect.isIPad(),
isAndroid : MobileDetect.isAndroidOS(),
isIOS : MobileDetect.isIOS(),
// Example of how to define a Cordova app when using the AppendUserAgent option in the Config.xml
// In this test I check for cordova which is what I append or Crosswalk
isCordova : MobileDetect.match("cordova|Crosswalk"),
// desktop version
isMacSafari : MobileDetect.match("Macintosh(.*)Version(.*)Safari"),
isPhone : MobileDetect.isMobile() && !MobileDetect.isTablet() ? true : false,
// Example of how I define a new version for a Cordova App
newCordova : MobileDetect.match("cordova 2|Crosswalk/17|cordova_in_browser")
};
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment