From 4a900964ddba12cdad244218b2221a060550c34e Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 12 Sep 2019 09:29:50 -0400 Subject: [PATCH 1/2] fix(platform): properly detect iPads running iPadOS (#19258) * Add support for iPadOS * add better test * small tweak --- core/src/utils/platform.ts | 17 ++++++++++++++--- core/src/utils/test/platform.spec.ts | 15 +++++++++++++-- core/src/utils/test/platform.utils.ts | 8 ++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/core/src/utils/platform.ts b/core/src/utils/platform.ts index 3134d8e28f..bdb7f40cc8 100644 --- a/core/src/utils/platform.ts +++ b/core/src/utils/platform.ts @@ -33,14 +33,25 @@ const detectPlatforms = (win: Window) => const isMobileWeb = (win: Window): boolean => isMobile(win) && !isHybrid(win); -const isIpad = (win: Window) => - testUserAgent(win, /iPad/i); +const isIpad = (win: Window) => { + // iOS 12 and below + if (testUserAgent(win, /iPad/i)) { + return true; + } + + // iOS 13+ + if (testUserAgent(win, /Macintosh/i) && isMobile(win)) { + return true; + } + + return false; +}; const isIphone = (win: Window) => testUserAgent(win, /iPhone/i); const isIOS = (win: Window) => - testUserAgent(win, /iPad|iPhone|iPod/i); + testUserAgent(win, /iPhone|iPod/i) || isIpad(win); const isAndroid = (win: Window) => testUserAgent(win, /android|sink/i); diff --git a/core/src/utils/test/platform.spec.ts b/core/src/utils/test/platform.spec.ts index 484262224d..478961c270 100644 --- a/core/src/utils/test/platform.spec.ts +++ b/core/src/utils/test/platform.spec.ts @@ -63,10 +63,11 @@ describe('Platform Tests', () => { expect(isPlatform(win, 'desktop')).toEqual(true); }); - it('should return true for "android" and "tablet" on an android tablet', () => { + it('should return true for "android" and "tablet" and false for "ios" on an android tablet', () => { const win = configureBrowser(PlatformConfiguration.AndroidTablet); expect(isPlatform(win, 'android')).toEqual(true); expect(isPlatform(win, 'tablet')).toEqual(true); + expect(isPlatform(win, 'ios')).toEqual(false); }); it('should return true for "cordova" and "hybrid" in a Cordova app', () => { @@ -95,10 +96,11 @@ describe('Platform Tests', () => { expect(isPlatform(win, 'desktop')).toEqual(false); }); - it('should return false for "android" and "tablet" on desktop Safari', () => { + it('should return false for "android", "tablet", and "ipad" on desktop Safari', () => { const win = configureBrowser(PlatformConfiguration.DesktopSafari); expect(isPlatform(win, 'android')).toEqual(false); expect(isPlatform(win, 'tablet')).toEqual(false); + expect(isPlatform(win, 'ipad')).toEqual(false); }); it('should return false for "android" and "tablet" and false for "desktop" on iPhone', () => { @@ -120,5 +122,14 @@ describe('Platform Tests', () => { expect(isPlatform(win, 'pwa')).toEqual(true); expect(isPlatform(win, 'cordova')).toEqual(false); }); + + it('should return true for "ios", "ipad", and "tablet" and false for "iphone" and "android"', () => { + const win = configureBrowser(PlatformConfiguration.iPadOS); + expect(isPlatform(win, 'ios')).toEqual(true); + expect(isPlatform(win, 'ipad')).toEqual(true); + expect(isPlatform(win, 'tablet')).toEqual(true); + expect(isPlatform(win, 'iphone')).toEqual(false); + expect(isPlatform(win, 'android')).toEqual(false); + }); }) }); \ No newline at end of file diff --git a/core/src/utils/test/platform.utils.ts b/core/src/utils/test/platform.utils.ts index 5e06d03c99..48abdbeb11 100644 --- a/core/src/utils/test/platform.utils.ts +++ b/core/src/utils/test/platform.utils.ts @@ -85,5 +85,13 @@ export const PlatformConfiguration = { innerWidth: 360, innerHeight: 740, matchMedia: mockMatchMedia(['(any-pointer:coarse)']) + }, + iPadOS: { + navigator: { + userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15' + }, + innerWidth: 1024, + innerHeight: 1292, + matchMedia: mockMatchMedia(['(any-pointer:coarse)']) } }; From f7027fc9ad58c4ecaf83d6904cc8706ea8739d63 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 16 Sep 2019 14:32:23 -0400 Subject: [PATCH 2/2] 4.9.1 --- CHANGELOG.md | 9 +++++++++ angular/package.json | 4 ++-- core/package.json | 2 +- docs/package.json | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2427e55d63..b0a546d450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [4.9.1](https://github.com/ionic-team/ionic/compare/v4.9.0...v4.9.1) (2019-09-16) + + +### Bug Fixes + +* **platform:** properly detect iPads running iPadOS ([#19258](https://github.com/ionic-team/ionic/issues/19258)) ([4a90096](https://github.com/ionic-team/ionic/commit/4a90096)) + + + # [4.9.0 Fluorine](https://github.com/ionic-team/ionic/compare/v4.8.1...v4.9.0) (2019-09-04) diff --git a/angular/package.json b/angular/package.json index 57c68b8d55..0493742b27 100644 --- a/angular/package.json +++ b/angular/package.json @@ -1,6 +1,6 @@ { "name": "@ionic/angular", - "version": "4.9.0", + "version": "4.9.1", "description": "Angular specific wrappers for @ionic/core", "keywords": [ "ionic", @@ -49,7 +49,7 @@ "css/" ], "dependencies": { - "@ionic/core": "4.9.0", + "@ionic/core": "4.9.1", "tslib": "^1.9.3" }, "peerDependencies": { diff --git a/core/package.json b/core/package.json index 8e004259ad..b632a922b6 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@ionic/core", - "version": "4.9.0", + "version": "4.9.1", "description": "Base components for Ionic", "keywords": [ "ionic", diff --git a/docs/package.json b/docs/package.json index 48a70618ee..63350a4884 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "@ionic/docs", - "version": "4.9.0", + "version": "4.9.1", "description": "Pre-packaged API documentation for the Ionic docs.", "main": "core.json", "files": [