From b6b43ae2925f8a12b35cabd43abd9d838bc9714f Mon Sep 17 00:00:00 2001 From: r-yanyo Date: Thu, 6 Mar 2025 10:14:36 +0900 Subject: [PATCH] fix(capacitor): replace deprecated platform check method (#30195) Issue number: resolves internal ref: https://github.com/ionic-team/capacitor/issues/7884 --------- ## What is the current behavior? `this.platform.is('capacitor')` returns `false` in Capacitor App. ## What is the new behavior? `this.platform.is('capacitor')` returns as expected. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information It might also need to be fixed. https://github.com/ionic-team/ionic-framework/blob/14b6538d98303cb753d881ec6978fb98f53ed54c/core/src/utils/test/platform.utils.ts#L32 --------- Co-authored-by: ShaneK --- core/src/utils/platform.ts | 3 ++- core/src/utils/test/platform.utils.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/utils/platform.ts b/core/src/utils/platform.ts index 622b81cac1..438bab0a42 100644 --- a/core/src/utils/platform.ts +++ b/core/src/utils/platform.ts @@ -99,7 +99,8 @@ const isCordova = (win: any): boolean => !!(win['cordova'] || win['phonegap'] || const isCapacitorNative = (win: any): boolean => { const capacitor = win['Capacitor']; - return !!capacitor?.isNative; + // TODO(ROU-11693): Remove when we no longer support Capacitor 2, which does not have isNativePlatform + return !!(capacitor?.isNative || (capacitor?.isNativePlatform && !!capacitor.isNativePlatform())); }; const isElectron = (win: Window): boolean => testUserAgent(win, /electron/i); diff --git a/core/src/utils/test/platform.utils.ts b/core/src/utils/test/platform.utils.ts index 0cc7bce9b2..a9235d8024 100644 --- a/core/src/utils/test/platform.utils.ts +++ b/core/src/utils/test/platform.utils.ts @@ -29,7 +29,7 @@ export const PlatformConfiguration = { }, Capacitor: { Capacitor: { - isNative: true, + isNativePlatform: () => true, }, }, PWA: {