Skip to content

Commit b6b43ae

Browse files
r-yanyoShaneK
andauthored
fix(capacitor): replace deprecated platform check method (#30195)
Issue number: resolves internal ref: ionic-team/capacitor#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. https://github.com/ionic-team/ionic-framework/blob/14b6538d98303cb753d881ec6978fb98f53ed54c/core/src/utils/test/platform.utils.ts#L32 --------- Co-authored-by: ShaneK <[email protected]>
1 parent 7794a11 commit b6b43ae

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

core/src/utils/platform.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ const isCordova = (win: any): boolean => !!(win['cordova'] || win['phonegap'] ||
9999

100100
const isCapacitorNative = (win: any): boolean => {
101101
const capacitor = win['Capacitor'];
102-
return !!capacitor?.isNative;
102+
// TODO(ROU-11693): Remove when we no longer support Capacitor 2, which does not have isNativePlatform
103+
return !!(capacitor?.isNative || (capacitor?.isNativePlatform && !!capacitor.isNativePlatform()));
103104
};
104105

105106
const isElectron = (win: Window): boolean => testUserAgent(win, /electron/i);

core/src/utils/test/platform.utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const PlatformConfiguration = {
2929
},
3030
Capacitor: {
3131
Capacitor: {
32-
isNative: true,
32+
isNativePlatform: () => true,
3333
},
3434
},
3535
PWA: {

0 commit comments

Comments
 (0)