[ https://issues.apache.org/jira/browse/CB-12105?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Veenstra updated CB-12105: ------------------------------- Description: When building for platform browser the {{cordova-plugin-device}} (v1.3.2) returns "Chrome" instead of "Edge" when requesting {{window.device.model}} on an Edge browser. In the {{DeviceProxy.js}} the following code is there: https://github.com/apache/cordova-plugin-device/blob/master/src/browser/DeviceProxy.js#L40 {code} function getBrowserInfo(getModel) { var userAgent = navigator.userAgent; var returnVal = ''; var offset; if ((offset = userAgent.indexOf('Chrome')) !== -1) { returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); } else if ((offset = userAgent.indexOf('Safari')) !== -1) { if (getModel) { returnVal = 'Safari'; } else { returnVal = userAgent.substring(offset + 7); if ((offset = userAgent.indexOf('Version')) !== -1) { returnVal = userAgent.substring(offset + 8); } } } else if ((offset = userAgent.indexOf('Firefox')) !== -1) { returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8); } else if ((offset = userAgent.indexOf('MSIE')) !== -1) { returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5); } else if ((offset = userAgent.indexOf('Trident')) !== -1) { returnVal = (getModel) ? 'MSIE' : '11'; } if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) { returnVal = returnVal.substring(0, offset); } return returnVal; } {code} The code above returns model Chrome as soon as it is in the userAgent string. MS Edge provides the following userAgent string: {{Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393}} So it seems we should be checking first if "Edge" is part of the userAgent. If so the browser would be Edge. was: When building for platform browser the {{cordova-plugin-device}} (v1.3.2) returns "Chrome" instead of "Edge" when requesting `window.device.model` on an Edge browser. In the `DeviceProxy.js` the following code is there: https://github.com/apache/cordova-plugin-device/blob/master/src/browser/DeviceProxy.js#L40 {code} function getBrowserInfo(getModel) { var userAgent = navigator.userAgent; var returnVal = ''; var offset; if ((offset = userAgent.indexOf('Chrome')) !== -1) { returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); } else if ((offset = userAgent.indexOf('Safari')) !== -1) { if (getModel) { returnVal = 'Safari'; } else { returnVal = userAgent.substring(offset + 7); if ((offset = userAgent.indexOf('Version')) !== -1) { returnVal = userAgent.substring(offset + 8); } } } else if ((offset = userAgent.indexOf('Firefox')) !== -1) { returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8); } else if ((offset = userAgent.indexOf('MSIE')) !== -1) { returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5); } else if ((offset = userAgent.indexOf('Trident')) !== -1) { returnVal = (getModel) ? 'MSIE' : '11'; } if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) { returnVal = returnVal.substring(0, offset); } return returnVal; } {code} The code above returns model Chrome as soon as it is in the userAgent string. MS Edge provides the following userAgent string: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393` So it seems we should be checking first if "Edge" is part of the userAgent. If so the browser would be Edge. > window.device.model returns "Chrome" instead of "Edge" when using MS Edge > ------------------------------------------------------------------------- > > Key: CB-12105 > URL: https://issues.apache.org/jira/browse/CB-12105 > Project: Apache Cordova > Issue Type: Bug > Components: Plugin Device > Affects Versions: 6.3.2 > Reporter: Mark Veenstra > Priority: Critical > > When building for platform browser the {{cordova-plugin-device}} (v1.3.2) > returns "Chrome" instead of "Edge" when requesting {{window.device.model}} on > an Edge browser. > In the {{DeviceProxy.js}} the following code is there: > https://github.com/apache/cordova-plugin-device/blob/master/src/browser/DeviceProxy.js#L40 > {code} > function getBrowserInfo(getModel) { > var userAgent = navigator.userAgent; > var returnVal = ''; > var offset; > if ((offset = userAgent.indexOf('Chrome')) !== -1) { > returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); > } else if ((offset = userAgent.indexOf('Safari')) !== -1) { > if (getModel) { > returnVal = 'Safari'; > } else { > returnVal = userAgent.substring(offset + 7); > if ((offset = userAgent.indexOf('Version')) !== -1) { > returnVal = userAgent.substring(offset + 8); > } > } > } else if ((offset = userAgent.indexOf('Firefox')) !== -1) { > returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8); > } else if ((offset = userAgent.indexOf('MSIE')) !== -1) { > returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5); > } else if ((offset = userAgent.indexOf('Trident')) !== -1) { > returnVal = (getModel) ? 'MSIE' : '11'; > } > if ((offset = returnVal.indexOf(';')) !== -1 || (offset = > returnVal.indexOf(' ')) !== -1) { > returnVal = returnVal.substring(0, offset); > } > return returnVal; > } > {code} > The code above returns model Chrome as soon as it is in the userAgent string. > MS Edge provides the following userAgent string: {{Mozilla/5.0 (Windows NT > 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 > Safari/537.36 Edge/14.14393}} > So it seems we should be checking first if "Edge" is part of the userAgent. > If so the browser would be Edge. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org