mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
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:
@@ -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);
|
||||
|
||||
@@ -29,7 +29,7 @@ export const PlatformConfiguration = {
|
||||
},
|
||||
Capacitor: {
|
||||
Capacitor: {
|
||||
isNative: true,
|
||||
isNativePlatform: () => true,
|
||||
},
|
||||
},
|
||||
PWA: {
|
||||
|
||||
Reference in New Issue
Block a user