メインコンテンツにジャンプ

始めてみる

GitHub

Capgo の AI 助成インストール機能を使用してプラグインをインストールできます。AI ツールに Capgo スキルを追加するには、以下のコマンドを実行してください。

ターミナル ウィンドウ
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用してください。

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

Manual Setup を使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の説明を参照してください。

ターミナルウィンドウ
bun add @capgo/capacitor-wechat
bunx cap sync
import { CapacitorWechat } from '@capgo/capacitor-wechat';

SDK を使用して、ウェブチャットアプリケーションにアプリケーション認証情報を設定します。

これらの値を、プラグインの構成下で設定することもできます。 このメソッドを呼び出すと、実行時にはバンドルされた構成が上書きされます。 capacitor.config.ts 「{0}」セクション CapacitorWechat ウェブチャット {0} を使用して、アプリケーション認証情報を設定します。

import { CapacitorWechat } from '@capgo/capacitor-wechat';
await CapacitorWechat.initialize({
appId: 'wx1234567890',
universalLink: 'https://example.com/app/'
});

isInstalled

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

import { CapacitorWechat } from '@capgo/capacitor-wechat';
const { installed } = await CapacitorWechat.isInstalled();
if (installed) {
console.log('WeChat is installed');
}

__CAPGO_KEEP_3__

import { CapacitorWechat } from '@capgo/capacitor-wechat';
const { code, state } = await CapacitorWechat.auth({
scope: 'snsapi_userinfo',
state: 'my_state'
});
// Use code to get access token from your server

__CAPGO_KEEP_4__

import { CapacitorWechat } from '@capgo/capacitor-wechat';
// Share text
await CapacitorWechat.share({
scene: 0, // 0 = Session, 1 = Timeline, 2 = Favorite
type: 'text',
text: 'Hello WeChat!'
});
// Share link
await CapacitorWechat.share({
scene: 1,
type: 'link',
title: 'My Website',
description: 'Check out my website',
link: 'https://example.com',
imageUrl: 'https://example.com/image.jpg'
});

sendPaymentRequest

__CAPGO_KEEP_1__

__CAPGO_KEEP_5__

import { CapacitorWechat } from '@capgo/capacitor-wechat';
// Get payment params from your server first
const paymentParams = await fetchPaymentParamsFromServer();
await CapacitorWechat.sendPaymentRequest({
partnerId: paymentParams.partnerId,
prepayId: paymentParams.prepayId,
nonceStr: paymentParams.nonceStr,
timeStamp: paymentParams.timeStamp,
package: paymentParams.package,
sign: paymentParams.sign
});

openMiniProgram

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

import { CapacitorWechat } from '@capgo/capacitor-wechat';
const { extMsg } = await CapacitorWechat.openMiniProgram({
username: 'gh_xxxxxxxxxxxxx',
path: 'pages/index/index',
type: 0 // 0 = Release, 1 = Test, 2 = Preview
});

chooseInvoice

__CAPGO_KEEP_1__

__CAPGO_KEEP_3__

import { CapacitorWechat } from '@capgo/capacitor-wechat';
const { cards } = await CapacitorWechat.chooseInvoice({
appId: 'your_app_id',
signType: 'SHA1',
cardSign: 'signature',
timeStamp: '1234567890',
nonceStr: 'random_string'
});
console.log('Selected cards:', cards);

__CAPGO_KEEP_4__

__CAPGO_KEEP_5__

WechatInitializationOptions

__CAPGO_KEEP_6__

__CAPGO_KEEP_7__

export interface WechatInitializationOptions {
/**
* Required WeChat application ID.
*/
appId: string;
/**
* iOS universal link that is associated with your WeChat application.
*/
universalLink?: string;
}

WeChat認証オプション

export interface WechatAuthOptions {
/**
* OAuth scope. Use 'snsapi_userinfo' for user info or 'snsapi_login' for login only.
*/
scope: string;
/**
* Optional state parameter for CSRF protection.
*/
state?: string;
}

WeChat認証応答

export interface WechatAuthResponse {
/**
* Authorization code to exchange for access token.
*/
code: string;
/**
* State parameter if provided in request.
*/
state?: string;
}

WeChatシェアオプション

export interface WechatShareOptions {
/**
* Share scene: 0 = Session (chat), 1 = Timeline (moments), 2 = Favorite.
*/
scene: number;
/**
* Share type: 'text', 'image', 'link', 'music', 'video', 'miniprogram'.
*/
type: 'text' | 'image' | 'link' | 'music' | 'video' | 'miniprogram';
/**
* Text content (for type 'text').
*/
text?: string;
/**
* Title (for type 'link', 'music', 'video', 'miniprogram').
*/
title?: string;
/**
* Description (for type 'link', 'music', 'video', 'miniprogram').
*/
description?: string;
/**
* Link URL (for type 'link').
*/
link?: string;
/**
* Image URL or base64 data.
*/
imageUrl?: string;
/**
* Thumbnail URL or base64 data (for type 'link', 'music', 'video').
*/
thumbUrl?: string;
/**
* Music or video URL (for type 'music', 'video').
*/
mediaUrl?: string;
/**
* Mini-program username (for type 'miniprogram').
*/
miniProgramUsername?: string;
/**
* Mini-program path (for type 'miniprogram').
*/
miniProgramPath?: string;
/**
* Mini-program type: 0 = Release, 1 = Test, 2 = Preview (for type 'miniprogram').
*/
miniProgramType?: number;
/**
* Mini-program web page URL fallback (for type 'miniprogram').
*/
miniProgramWebPageUrl?: string;
}

WeChat決済オプション

export interface WechatPaymentOptions {
/**
* Partner ID (merchant ID).
*/
partnerId: string;
/**
* Prepay ID from unified order API.
*/
prepayId: string;
/**
* Random string.
*/
nonceStr: string;
/**
* Timestamp.
*/
timeStamp: string;
/**
* Package value, typically 'Sign=WXPay'.
*/
package: string;
/**
* Signature.
*/
sign: string;
}

WechatMiniProgramOptions

WeChat mini-program の設定

WeChat mini-program の設定。

export interface WechatMiniProgramOptions {
/**
* Mini-program username (original ID).
*/
username: string;
/**
* Path to open in mini-program.
*/
path?: string;
/**
* Mini-program type: 0 = Release, 1 = Test, 2 = Preview.
*/
type?: number;
}

WeChat ใบเสร็จの設定。

export interface WechatInvoiceOptions {
/**
* App ID.
*/
appId: string;
/**
* Signature type.
*/
signType: string;
/**
* Card signature.
*/
cardSign: string;
/**
* Timestamp.
*/
timeStamp: string;
/**
* Random string.
*/
nonceStr: string;
}

WeChat ใบเสร็จの応答。

export interface WechatInvoiceResponse {
/**
* Array of selected card IDs.
*/
cards: WechatInvoiceCard[];
}

WeChat ใบเสร็จのカードアイテム。

export interface WechatInvoiceCard {
/**
* The selected card identifier.
*/
cardId: string;
/**
* Encrypted code returned by WeChat.
*/
encryptCode?: string;
}

真実の源

「真実の源」

このページはプラグインの src/definitions.ts上流でpublic APIが変更された場合に再度syncを実行してください。

Getting Startedから続けてください

「Getting Startedから続けてください」

あなたが Getting Started ダッシュボードとAPIの計画と操作を行う場合に接続してください。 Using @capgo/capacitor-wechat Using @capgo/capacitor-wechat のネイティブ機能のAPIの概要 API の実装詳細については Introduction __CAPGO_KEEP_0__ のキーの実装詳細については API Keys API Keys の実装詳細については、 Devices __CAPGO_KEEP_0__ の実装詳細については Devices.