Capacitor Native Market
Native Market
capacitor-community/native-market 2.0 에서만 동작하므로 아래 것을 다운 받아서 처리 그리고 별도의 component를 제작해서 처리한다.
install
npm i https://github.com/hermitdemschoenenleben/native-market
사용법
import { Capacitor } from '@capacitor/core';
import { NativeMarket } from './components/native-market';
..........
public async gotoMarket(id: string) {
if (Capacitor.isNativePlatform()) {
NativeMarket.openStoreListing({
appId: id,
});
}
}
native-market
- components
- native-market
- definitions.ts
- index.ts
- web.ts
- definitions.ts
export interface NativeMarketPlugin {
openStoreListing(options: { appId: string }): Promise<void>;
openDevPage(options: { devId: string }): Promise<void>;
openCollection(options: { name: string }): Promise<void>;
openEditorChoicePage(options: { editorChoice: string }): Promise<void>;
search(options: { terms: string }): Promise<void>;
}
- index.ts
import { registerPlugin } from '@capacitor/core';
import { NativeMarketPlugin } from './definitions';
const NativeMarket = registerPlugin<NativeMarketPlugin>('NativeMarket', {
web: () => import('./web').then((m) => new m.NativeMarketWeb()),
});
export * from './definitions';
export { NativeMarket };
- web.ts
import { WebPlugin } from '@capacitor/core';
import { NativeMarketPlugin } from './definitions';
export class NativeMarketWeb extends WebPlugin implements NativeMarketPlugin {
constructor() {
super({
name: 'NativeMarket',
platforms: ['web'],
});
}
openStoreListing(_options: { appId: string }): Promise<void> {
throw this.unimplemented('Not implemented on web.');
}
openDevPage(_options: { devId: string }): Promise<void> {
throw this.unimplemented('Not implemented on web.');
}
openCollection(_options: { name: string }): Promise<void> {
throw this.unimplemented('Not implemented on web.');
}
openEditorChoicePage(_options: { editorChoice: string }): Promise<void> {
throw this.unimplemented('Not implemented on web.');
}
search(_options: { terms: string }): Promise<void> {
throw this.unimplemented('Not implemented on web.');
}
}
const NativeMarket = new NativeMarketWeb();
export { NativeMarket };