시작하기
-
패키지 설치
Terminal window npm i @capgo/native-marketTerminal window pnpm add @capgo/native-marketTerminal window yarn add @capgo/native-marketTerminal window bun add @capgo/native-market -
네이티브 프로젝트와 동기화
Terminal window npx cap syncTerminal window pnpm cap syncTerminal window yarn cap syncTerminal window bunx cap sync
플러그인을 가져와서 메서드를 사용하여 사용자를 앱 스토어로 리디렉션하세요:
import { NativeMarket } from '@capgo/native-market';
// 앱 스토어 목록 열기const openAppStore = async () => { await NativeMarket.openStoreListing({ appId: 'com.example.app' // 앱의 번들 ID });};
// 앱 리뷰 요청const requestReview = async () => { await NativeMarket.requestReview();};
// 앱 스토어 검색 열기const searchInStore = async () => { await NativeMarket.search({ terms: 'fitness app' // 검색어 });};API 참조
Section titled “API 참조”openStoreListing(options)
Section titled “openStoreListing(options)”지정된 앱의 앱 스토어 목록을 엽니다.
interface OpenStoreListingOptions { appId: string; // iOS의 번들 ID, Android의 패키지 이름}requestReview()
Section titled “requestReview()”사용자에게 앱 내 리뷰를 요청합니다. iOS 10.3+에서는 앱을 떠나지 않고 평가 대화 상자를 표시합니다.
search(options)
Section titled “search(options)”검색 결과와 함께 앱 스토어를 엽니다.
interface SearchOptions { terms: string; // 사용할 검색어}플랫폼 참고사항
Section titled “플랫폼 참고사항”- iOS 10.3+에서 앱 내 리뷰에
SKStoreReviewController사용 - 이전 버전에서는 App Store를 여는 것으로 대체
Android
Section titled “Android”- Google Play Store 열기
- 사용 가능한 경우 앱 내 리뷰 API 사용
import { NativeMarket } from '@capgo/native-market';import { Capacitor } from '@capacitor/core';
export class AppService { async rateApp() { try { // 먼저 앱 내 리뷰 시도 await NativeMarket.requestReview(); } catch (error) { // 스토어 목록 열기로 대체 const platform = Capacitor.getPlatform(); const appId = platform === 'ios' ? 'id123456789' // iOS 앱 ID : 'com.example.app'; // Android 패키지 이름
await NativeMarket.openStoreListing({ appId }); } }}