Skip to content

Commit 2ff174e

Browse files
author
pandamicro
committed
Improve platform detection
1 parent c1d6270 commit 2ff174e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

CCBoot.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ var _initSys = function () {
16661666
* @name isMobile
16671667
* @type {Boolean}
16681668
*/
1669-
sys.isMobile = ua.indexOf('mobile') !== -1 || ua.indexOf('android') !== -1;
1669+
sys.isMobile = /mobile|android|iphone|ipad/.test(ua);
16701670

16711671
/**
16721672
* Indicate the running platform
@@ -1701,6 +1701,11 @@ var _initSys = function () {
17011701
iOS = true;
17021702
osVersion = uaResult[2] || '';
17031703
osMainVersion = parseInt(osVersion) || 0;
1704+
}
1705+
else if (/(iPhone|iPad|iPod)/.exec(nav.platform)) {
1706+
iOS = true;
1707+
osVersion = '';
1708+
osMainVersion = 0;
17041709
}
17051710

17061711
var osName = sys.OS_UNKNOWN;
@@ -2089,7 +2094,7 @@ function _afterEngineLoaded(config) {
20892094
if (cc._initDebugSetting)
20902095
cc._initDebugSetting(config[cc.game.CONFIG_KEY.debugMode]);
20912096
cc._engineLoaded = true;
2092-
cc.log(cc.ENGINE_VERSION);
2097+
console.log(cc.ENGINE_VERSION);
20932098
if (_engineLoadedCallback) _engineLoadedCallback();
20942099
}
20952100

0 commit comments

Comments
 (0)