Anfangen
Kopieren Sie einen Einrichtungshinweis mit den Installationsanweisungen und der vollständigen Markdown-Guideline für diesen Plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-wechat`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/wechat/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Abschnitt mit dem Titel „Installieren“
Sie können unsere AI-gestützte Einrichtung verwenden, um das Plugin zu installieren. Fügen Sie die __CAPGO_KEEP_0__-Fähigkeiten zu Ihrem KI-Tool hinzu, indem Sie die folgende Befehlszeile verwenden:You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsIncludes install, sync, and the source markdown guide.
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-wechat` plugin in my project.Wenn Sie eine manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und die unten angegebenen Plattform-spezifischen Anweisungen befolgen:
bun add @capgo/capacitor-wechatbunx cap syncImportieren
Abschnitt mit dem Titel „Importieren“import { CapacitorWechat } from '@capgo/capacitor-wechat';API Übersicht
Abschnitt mit dem Titel „API Übersicht“initialize
Abschnitt mit dem Titel „Initialisieren“Initialisieren Sie das WeChat SDK mit Ihren Anwendungsanmeldeinformationen.
Sie können diese Werte auch in capacitor.config.ts unter der CapacitorWechat
Plugin-Konfiguration. Aufrufen dieser Methode überschreibt jede konfigurierte Einstellung im Laufzeitumfeld.
import { CapacitorWechat } from '@capgo/capacitor-wechat';
await CapacitorWechat.initialize({ appId: 'wx1234567890', universalLink: 'https://example.com/app/'});isInstalled
Sektion mit dem Titel „isInstalled“Überprüfen Sie, ob die WeChat-App auf dem Gerät installiert ist.
import { CapacitorWechat } from '@capgo/capacitor-wechat';
const { installed } = await CapacitorWechat.isInstalled();if (installed) { console.log('WeChat is installed');}Authentifizieren Sie den Benutzer mit 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 serverTeilen Sie Inhalte über WeChat.
import { CapacitorWechat } from '@capgo/capacitor-wechat';
// Share textawait CapacitorWechat.share({ scene: 0, // 0 = Session, 1 = Timeline, 2 = Favorite type: 'text', text: 'Hello WeChat!'});
// Share linkawait 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
Abschnitt mit dem Titel “sendPaymentRequest”Zahlungsanfrage an WeChat Pay senden.
import { CapacitorWechat } from '@capgo/capacitor-wechat';
// Get payment params from your server firstconst 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
Abschnitt mit dem Titel “openMiniProgram”WeChat-Miniprogramm öffnen.
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
Abschnitt mit dem Titel “chooseInvoice”Rechnung aus WeChat auswählen.
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);Typenreferenz
Abschnitt mit dem Titel “Typenreferenz”WechatInitializationOptions
Abschnitt mit dem Titel “WechatInitializationOptions”WeChat-Initialisierungsoptionen.
export interface WechatInitializationOptions { /** * Required WeChat application ID. */ appId: string;
/** * iOS universal link that is associated with your WeChat application. */ universalLink?: string;}WechatAuthOptions
Abschnitt mit dem Titel „WechatAuthOptions“WeChat-Authentifizierungsoptionen.
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
Abschnitt mit dem Titel „WechatAuthResponse“WeChat-Authentifizierungsantwort.
export interface WechatAuthResponse { /** * Authorization code to exchange for access token. */ code: string;
/** * State parameter if provided in request. */ state?: string;}WechatShareOptions
Abschnitt mit dem Titel „WechatShareOptions“WeChat-Teilnahmeoptionen.
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
Abschnitt mit dem Titel „WechatPaymentOptions“WeChat-Zahlungsoptionen.
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
Abschnitt mit dem Titel „WechatMiniProgramOptions“WeChat-Miniprogrammoptionen.
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
Abschnitt mit dem Titel „WechatInvoiceOptions“WeChat-Rechnungsoptionen.
export interface WechatInvoiceOptions { /** * App ID. */ appId: string;
/** * Signature type. */ signType: string;
/** * Card signature. */ cardSign: string;
/** * Timestamp. */ timeStamp: string;
/** * Random string. */ nonceStr: string;}WechatInvoiceResponse
Abschnitt mit dem Titel „WechatInvoiceResponse“WeChat-Rechnungsergebnis.
export interface WechatInvoiceResponse { /** * Array of selected card IDs. */ cards: WechatInvoiceCard[];}WechatInvoiceCard
Abschnitt mit dem Titel „WechatInvoiceCard“WeChat Rechnungskartenartikel.
export interface WechatInvoiceCard { /** * The selected card identifier. */ cardId: string;
/** * Encrypted code returned by WeChat. */ encryptCode?: string;}Quelle der Wahrheit
Abschnitt mit dem Titel „Quelle der Wahrheit“Diese Seite wurde aus dem Plugin generiert. src/definitions.tsWenn sich die öffentliche API im Quellcode ändert, führen Sie die Synchronisierung erneut durch.
Weiter von Anfang an
Abschnitt mit dem Titel „Weiter von Anfang an“Wenn Sie das Plugin verwenden Anfang um das Dashboard und die API-Operationen zu planen, verbinden Sie es mit Verwenden Sie @capgo/capacitor-wechat für die native Fähigkeit in @capgo/capacitor-wechat, API Übersicht für die Implementierungsdetails in API Übersicht, Einführung für die Implementierungsdetails in Einführung, API Schlüssel für die Implementierungsdetails in API Schlüssel und Geräte für die Implementierungsdetails in Geräte.