Zum Inhalt springen

Getting Started

Dieser Inhalt ist in Ihrer Sprache noch nicht verfügbar.

  1. Install the package

    Terminal-Fenster
    npm i @capgo/native-market
  2. Sync with native projects

    Terminal-Fenster
    npx cap sync

Usage

Import the plugin and use its methods to redirect users to app stores:

import { NativeMarket } from '@capgo/native-market';
// Open app store listing
const openAppStore = async () => {
await NativeMarket.openStoreListing({
appId: 'com.example.app' // Your app's bundle ID
});
};
// Request app review
const requestReview = async () => {
await NativeMarket.requestReview();
};
// Open app store search
const searchInStore = async () => {
await NativeMarket.search({
terms: 'fitness app' // Search terms
});
};

API Reference

openStoreListing(options)

Opens the app store listing for the specified app.

interface OpenStoreListingOptions {
appId: string; // Bundle ID on iOS, Package name on Android
}

requestReview()

Requests an in-app review from the user. On iOS 10.3+, this shows the rating dialog without leaving the app.

search(options)

Opens the app store with search results.

interface SearchOptions {
terms: string; // Search terms to use
}

Platform Notes

iOS

  • Uses SKStoreReviewController for in-app reviews on iOS 10.3+
  • Falls back to opening App Store for older versions

Android

  • Opens Google Play Store
  • Uses in-app review API when available

Example

import { NativeMarket } from '@capgo/native-market';
import { Capacitor } from '@capacitor/core';
export class AppService {
async rateApp() {
try {
// Try in-app review first
await NativeMarket.requestReview();
} catch (error) {
// Fallback to opening store listing
const platform = Capacitor.getPlatform();
const appId = platform === 'ios'
? 'id123456789' // Your iOS app ID
: 'com.example.app'; // Your Android package name
await NativeMarket.openStoreListing({ appId });
}
}
}