From 0086170a232b0e84f2c2dc3e4e2ad2cf4a4055b9 Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Thu, 2 Feb 2017 14:22:38 -0600 Subject: [PATCH 1/2] fix(platform): iPad pro is detected as an iPad --- src/platform/platform.ts | 10 ++++++++++ src/platform/test/platform.spec.ts | 31 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/platform/platform.ts b/src/platform/platform.ts index 64e813d8b9b..61f04c24697 100644 --- a/src/platform/platform.ts +++ b/src/platform/platform.ts @@ -986,6 +986,16 @@ export class Platform { while (platformNode) { platformNode.initialize(this); + // extra check for ipad pro issue + // https://forums.developer.apple.com/thread/25948 + if (platformNode.name === 'iphone' && this.navigatorPlatform() === 'iPad') { + // this is an ipad pro so push ipad and tablet to platforms + // and then return as we are done + this._platforms.push('ipad'); + this._platforms.push('tablet'); + return; + } + // set the array of active platforms with // the last one in the array the most important this._platforms.push(platformNode.name); diff --git a/src/platform/test/platform.spec.ts b/src/platform/test/platform.spec.ts index a1b10def8ff..596298efc74 100644 --- a/src/platform/test/platform.spec.ts +++ b/src/platform/test/platform.spec.ts @@ -363,6 +363,37 @@ describe('Platform', () => { expect(plt.is('tablet')).toEqual(true); }); + // for https://forums.developer.apple.com/thread/25948 + it('should set ipad when user agent is iphone but navigator.platform is iPad', () => { + plt.setQueryParams(''); + plt.setUserAgent(IPHONE_UA); + plt.setNavigatorPlatform('iPad'); + plt.init(); + + expect(plt.is('core')).toEqual(false); + expect(plt.is('mobile')).toEqual(true); + expect(plt.is('windows')).toEqual(false); + expect(plt.is('android')).toEqual(false); + expect(plt.is('ios')).toEqual(true); + expect(plt.is('ipad')).toEqual(true); + expect(plt.is('iphone')).toEqual(false); + expect(plt.is('tablet')).toEqual(true); + + plt.setQueryParams(''); + plt.setUserAgent(IPHONE_10_2_UA); + plt.setNavigatorPlatform('iPad'); + plt.init(); + + expect(plt.is('core')).toEqual(false); + expect(plt.is('mobile')).toEqual(true); + expect(plt.is('windows')).toEqual(false); + expect(plt.is('android')).toEqual(false); + expect(plt.is('ios')).toEqual(true); + expect(plt.is('ipad')).toEqual(true); + expect(plt.is('iphone')).toEqual(false); + expect(plt.is('tablet')).toEqual(true); + }); + it('should set core platform for osx desktop firefox', () => { plt.setQueryParams(''); plt.setDefault('core'); From c58948b66190d5b8233914c026a398f7013e892a Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Thu, 2 Feb 2017 14:29:28 -0600 Subject: [PATCH 2/2] chore(platform): ipad should be last --- src/platform/platform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/platform.ts b/src/platform/platform.ts index 61f04c24697..2fd0c33d042 100644 --- a/src/platform/platform.ts +++ b/src/platform/platform.ts @@ -991,8 +991,8 @@ export class Platform { if (platformNode.name === 'iphone' && this.navigatorPlatform() === 'iPad') { // this is an ipad pro so push ipad and tablet to platforms // and then return as we are done - this._platforms.push('ipad'); this._platforms.push('tablet'); + this._platforms.push('ipad'); return; }