diff --git a/src/components/apphost.js b/src/components/apphost.js index 2ae64f97b0..39cfabbe4c 100644 --- a/src/components/apphost.js +++ b/src/components/apphost.js @@ -360,18 +360,20 @@ export const appHost = { }; }, deviceName: function () { - return window.NativeShell && window.NativeShell.AppHost.deviceName + return window.NativeShell?.AppHost?.deviceName ? window.NativeShell.AppHost.deviceName() : getDeviceName(); }, deviceId: function () { - return window.NativeShell && window.NativeShell.AppHost.deviceId + return window.NativeShell?.AppHost?.deviceId ? window.NativeShell.AppHost.deviceId() : getDeviceId(); }, appName: function () { - return window.NativeShell ? window.NativeShell.AppHost.appName() : appName; + return window.NativeShell?.AppHost?.appName + ? window.NativeShell.AppHost.appName() : appName; }, appVersion: function () { - return window.NativeShell ? window.NativeShell.AppHost.appVersion() : appVersion; + return window.NativeShell?.AppHost?.appVersion + ? window.NativeShell.AppHost.appVersion() : appVersion; }, getPushTokenInfo: function () { return {}; diff --git a/src/scripts/shell.js b/src/scripts/shell.js index 9a0ac76811..aba8698cdb 100644 --- a/src/scripts/shell.js +++ b/src/scripts/shell.js @@ -1,29 +1,29 @@ // TODO: This seems like a good candidate for deprecation export default { enableFullscreen: function() { - if (window.NativeShell && window.NativeShell.enableFullscreen) { + if (window.NativeShell?.enableFullscreen) { window.NativeShell.enableFullscreen(); } }, disableFullscreen: function() { - if (window.NativeShell && window.NativeShell.disableFullscreen) { + if (window.NativeShell?.disableFullscreen) { window.NativeShell.disableFullscreen(); } }, openUrl: function(url, target) { - if (window.NativeShell) { + if (window.NativeShell?.openUrl) { window.NativeShell.openUrl(url, target); } else { window.open(url, target || '_blank'); } }, updateMediaSession(mediaInfo) { - if (window.NativeShell && window.NativeShell.updateMediaSession) { + if (window.NativeShell?.updateMediaSession) { window.NativeShell.updateMediaSession(mediaInfo); } }, hideMediaSession() { - if (window.NativeShell && window.NativeShell.hideMediaSession) { + if (window.NativeShell?.hideMediaSession) { window.NativeShell.hideMediaSession(); } }, @@ -32,7 +32,7 @@ export default { * Useful for e.g. remote playback. */ updateVolumeLevel(volume) { - if (window.NativeShell && window.NativeShell.updateVolumeLevel) { + if (window.NativeShell?.updateVolumeLevel) { window.NativeShell.updateVolumeLevel(volume); } }, @@ -42,7 +42,7 @@ export default { * @returns true on success */ downloadFiles(items) { - if (window.NativeShell) { + if (window.NativeShell?.downloadFile) { items.forEach(item => window.NativeShell.downloadFile(item)); return true; }