はじめに
-
パッケージをインストール
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 }); } }}