Last active
January 4, 2016 20:09
-
-
Save szalishchuk/8672216 to your computer and use it in GitHub Desktop.
Detect whether the application is running in hybrid or browser mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='utf-8'?> | |
<widget id="com.phonegap.application" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"> | |
<access origin="*" /> | |
<content src="phonegap.html" /> | |
<name>Application</name> | |
<description>Description</description> | |
<author email="[email protected]" href="http://phonegap.com">Sviatoslav Zalishchuk</author> | |
<feature name="http://api.phonegap.com/1.0/device" /> | |
<preference name="permissions" value="none" /> | |
<preference name="orientation" value="default" /> | |
<preference name="target-device" value="universal" /> | |
<preference name="fullscreen" value="true" /> | |
<preference name="webviewbounce" value="true" /> | |
<preference name="prerendered-icon" value="true" /> | |
<preference name="stay-in-webview" value="false" /> | |
<preference name="ios-statusbarstyle" value="black-opaque" /> | |
<preference name="detect-data-types" value="true" /> | |
<preference name="exit-on-suspend" value="false" /> | |
<preference name="show-splash-screen-spinner" value="true" /> | |
<preference name="auto-hide-splash-screen" value="true" /> | |
<preference name="disable-cursor" value="false" /> | |
<preference name="android-minSdkVersion" value="7" /> | |
<preference name="android-installLocation" value="auto" /> | |
<icon src="icon.png" /> | |
<icon gap:density="ldpi" gap:platform="android" src="res/icon/android/icon-36-ldpi.png" /> | |
<icon gap:density="mdpi" gap:platform="android" src="res/icon/android/icon-48-mdpi.png" /> | |
<icon gap:density="hdpi" gap:platform="android" src="res/icon/android/icon-72-hdpi.png" /> | |
<icon gap:density="xhdpi" gap:platform="android" src="res/icon/android/icon-96-xhdpi.png" /> | |
<icon gap:platform="blackberry" src="res/icon/blackberry/icon-80.png" /> | |
<icon gap:platform="blackberry" gap:state="hover" src="res/icon/blackberry/icon-80.png" /> | |
<icon gap:platform="ios" height="57" src="res/icon/ios/icon-57.png" width="57" /> | |
<icon gap:platform="ios" height="72" src="res/icon/ios/icon-72.png" width="72" /> | |
<icon gap:platform="ios" height="114" src="res/icon/ios/icon-57-2x.png" width="114" /> | |
<icon gap:platform="ios" height="144" src="res/icon/ios/icon-72-2x.png" width="144" /> | |
<icon gap:platform="webos" src="res/icon/webos/icon-64.png" /> | |
<icon gap:platform="winphone" src="res/icon/windows-phone/icon-48.png" /> | |
<icon gap:platform="winphone" gap:role="background" src="res/icon/windows-phone/icon-173.png" /> | |
<gap:splash gap:density="ldpi" gap:platform="android" src="res/screen/android/screen-ldpi-portrait.png" /> | |
<gap:splash gap:density="mdpi" gap:platform="android" src="res/screen/android/screen-mdpi-portrait.png" /> | |
<gap:splash gap:density="hdpi" gap:platform="android" src="res/screen/android/screen-hdpi-portrait.png" /> | |
<gap:splash gap:density="xhdpi" gap:platform="android" src="res/screen/android/screen-xhdpi-portrait.png" /> | |
<gap:splash gap:platform="blackberry" src="res/screen/blackberry/screen-225.png" /> | |
<gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" /> | |
<gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" /> | |
<gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" /> | |
<gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" /> | |
<gap:splash gap:platform="winphone" src="res/screen/windows-phone/screen-portrait.jpg" /> | |
</widget> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="format-detection" content="telephone=no" /> | |
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> | |
<title>Application</title> | |
<link rel="stylesheet" href="styles/package.css"> | |
<script src="vendors/requirejs/require.js" data-main="scripts/config/main"></script> | |
</head> | |
<body> | |
<section id="page-wrap" class="page-wrap"></section> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Detect if the application runs on mobile or browser using JavaScript before the “deviceready” and document “ready” events are triggered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<script src="phonegap.js"></script> | |
<script> | |
// Determine whether the file loaded from PhoneGap or not | |
function isPhoneGap() { | |
return (cordova || PhoneGap || phonegap) | |
&& /^file:\/{3}[^\/]/i.test(window.location.href) | |
&& /ios|iphone|ipod|ipad|android/i.test(navigator.userAgent); | |
} | |
//ensure the 98% that this file is called from PhoneGap. | |
//in case somebody accessed this file directly from the browser. | |
if ( isPhoneGap() ) { | |
window.localStorage.setItem("isPhoneGap", true); | |
console.log('its a phonegap app'); | |
} | |
//and redirect to the main site file. | |
window.location = "index.html"; | |
</script> | |
</head> | |
<body></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment