跳转到正文

快速入门

GitHub

你可以使用我们的 AI 辅助设置来安装插件。使用以下命令将 Capgo skills 添加到你的 AI 工具中:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下 prompt:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-native-market` plugin in my project.

如果你更想手动设置,请运行以下命令安装插件,并按照下方各平台的说明操作:

终端窗口
npm install @capgo/capacitor-native-market
npx cap sync
import { NativeMarket } from '@capgo/capacitor-native-market';
import { NativeMarket } from '@capgo/capacitor-native-market';
await NativeMarket.openStoreListing({ appId: 'com.example.app' });

示例:Play Store 搜索(Android)

章节标题:“示例:Play Store 搜索 (Android)”
import { NativeMarket } from '@capgo/capacitor-native-market';
await NativeMarket.search({ terms: 'fitness tracker' });
  • Bundle 与 package:iOS 使用 App Store bundle id,Android 使用 application id。
  • 仅限 Android:guard openDevPage 以及 openCollection 配合 Capacitor.getPlatform().
  • 外部 UI:store UI 会在 WebView 之外打开,请单独规划 deep links 的返回逻辑。

在 Play Store (Android) 或 App Store (iOS) 中打开应用详情页。

import { NativeMarket } from '@capgo/capacitor-native-market';
// Open app in store
await NativeMarket.openStoreListing({
appId: 'com.example.app'
});
// Open app in specific country store (iOS only)
await NativeMarket.openStoreListing({
appId: 'com.example.app',
country: 'IT'
});

直接 deep link 到 Play Store 中的开发者页面。 仅限 Android。

import { NativeMarket } from '@capgo/capacitor-native-market';
await NativeMarket.openDevPage({
devId: 'Google+LLC'
});

引导用户前往 Play Store 中的合集或排行榜。 仅限 Android。

import { NativeMarket } from '@capgo/capacitor-native-market';
await NativeMarket.openCollection({
name: 'featured'
});

将用户引导至 Play Store 的“精选”页面。 仅限 Android。

import { NativeMarket } from '@capgo/capacitor-native-market';
await NativeMarket.openEditorChoicePage({
editorChoice: 'editorial_fitness_apps_us'
});

使用自定义搜索词搜索 Play Store。 仅限 Android。

import { NativeMarket } from '@capgo/capacitor-native-market';
await NativeMarket.search({
terms: 'fitness apps'
});

本页面由插件的 src/definitions.ts生成。当上游的公共 API 发生变化时,请重新运行 sync。

如果你正在使用 快速入门 要规划 dashboard 和 API 操作,请将其连接到 使用 @capgo/capacitor-native-market 在使用 @capgo/capacitor-native-market 时,关于原生能力, API 概览 关于 API Overview 中的实现细节, 简介 关于 Introduction 中的实现细节, API 密钥 有关 API Keys 的实现细节,以及 设备 有关 Devices 的实现细节。