fix(capacitor): replace deprecated platform check method (#30195)

Issue number: resolves internal

ref: https://github.com/ionic-team/capacitor/issues/7884

---------

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## 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.


14b6538d98/core/src/utils/test/platform.utils.ts (L32)

---------

Co-authored-by: ShaneK <shane@shanessite.net>
This commit is contained in:
r-yanyo
2025-03-06 10:14:36 +09:00
committed by GitHub
parent 7794a11215
commit b6b43ae292
2 changed files with 3 additions and 2 deletions

View File

@@ -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);

View File

@@ -29,7 +29,7 @@ export const PlatformConfiguration = {
},
Capacitor: {
Capacitor: {
isNative: true,
isNativePlatform: () => true,
},
},
PWA: {