내용으로 건너뛰기

WeChat __CAPGO_KEEP_0__ 저장소

GitHub

설치하기

설치 제목

Capgo의 AI-Assisted Setup을 사용하여 플러그인을 설치할 수 있습니다. 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';

initialize

초기화

WeChat SDK을 초기화하여 애플리케이션 자격 증명을 설정하세요.

이 값을 설정할 수도 있습니다. capacitor.config.ts WeChat 플러그인 CapacitorWechat 이 메소드를 호출하면 런타임에 배포된 구성이 덮어씌워집니다.

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

장치에 WeChat 앱이 설치되어 있는지 확인합니다.

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

WeChat OAuth를 사용하여 사용자를 인증합니다.

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

WeChat로 콘텐츠를 공유합니다.

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

sendPaymentRequest

WeChat Pay로 결제 요청을 보내세요.

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

openMiniProgram

WeChat 미니프로그램을 열어주세요.

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

chooseInvoice

WeChat에서 청구서를 선택해주세요.

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);

WechatInitializationOptions

타입 참조

WeChat 초기화 옵션.

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

WechatAuthOptions

WechatAuthOptions

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;
}

WechatAuthResponse

WechatAuthResponse

WeChat 인증 응답.

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

WechatShareOptions

WechatShareOptions

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;
}

WechatPaymentOptions

WechatPaymentOptions

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

WechatMiniProgramOptions 섹션

WeChat 미니프로그램 옵션.

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;
}

WechatInvoiceOptions

WechatInvoiceOptions 섹션

WeChat 청구서 옵션.

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

WechatInvoiceResponse

WechatInvoiceResponse 섹션

WeChat 청구서 응답.

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

WechatInvoiceCard

WechatInvoiceCard 섹션

WeChat 청구 카드 항목.

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

실질적인 진실

실질적인 진실

이 페이지는 플러그인의 src/definitions.ts공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.

Getting Started에서 계속

Getting Started에서 계속

이 플러그인을 사용하는 경우 Getting Started 계획 대시보드 및 API 운영을 위해 Using @capgo/capacitor-wechat Capgo의 Native 기능을 사용하는 @capgo/capacitor-wechat에 대해 API 개요 API Overview에 대한 구현 세부 정보 소개 소개에 대한 구현 세부 정보 API 키 API Keys에 대한 구현 세부 정보, 그리고 장치 장치에 대한 구현 세부 정보