Richtlinie
Tutorial auf WeChat
Mit @capgo/capacitor-wechat verwenden
Capacitor WeChat-Plugin - WeChat SDK-Integration für Authentifizierung, Teilen, Zahlungen und Mini-Programme
Installieren
bun add @capgo/capacitor-wechat
bunx cap sync
Was dieses Plugin bereitstellt
initialize- Initialisieren Sie das WeChat-SDK mit Ihren Anwendungsanmeldeinformationen.isInstalled- Überprüfen Sie, ob das WeChat-App auf dem Gerät installiert ist.auth- Authentifizieren Sie den Benutzer mit WeChat OAuth.share- Inhalt teilen auf WeChat.
Beispiel für die Verwendung
initialize
Initialisieren Sie die WeChat SDK mit Ihren Anwendungsanmeldeinformationen.
import { CapacitorWechat } from '@capgo/capacitor-wechat';
await CapacitorWechat.initialize({
appId: 'wx1234567890',
universalLink: 'https://example.com/app/'
});
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');
}
auth
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 server
share
Inhalt teilen auf 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'
});
Vollständige Referenz
- GitHub: https://github.com/Cap-go/capacitor-wechat/
- Dokumentation: /docs/plugins/wechat/