跨安装持久化
数据在应用卸载/重新安装循环中保持不变 💾
Capacitor Persistent Account 插件能够在应用安装之间安全存储和持久化用户账户数据。此插件确保即使在应用重新安装后,用户账户信息仍然可用,提供无缝的用户体验和账户连续性。
跨安装持久化
数据在应用卸载/重新安装循环中保持不变 💾
安全存储
通过系统集成实现安全的账户数据存储 🔐
简单的 API
用于账户管理的清晰读写接口 📊
跨平台
原生 iOS 和 Android 实现 📱
npm install @capgo/capacitor-persistent-accountnpx cap syncsaveAccount(options: { data: unknown }) - 安全地保存账户数据到持久化存储readAccount() - 检索已存储的账户数据,返回 Promise<{ data: unknown | null }>import { PersistentAccount } from '@capgo/capacitor-persistent-account';
// 定义您的账户数据结构interface UserAccount { userId: string; username: string; email: string; preferences: { theme: string; notifications: boolean; };}
// 保存账户数据const accountData: UserAccount = { userId: '12345', username: 'john_doe', email: 'john@example.com', preferences: { theme: 'dark', notifications: true }};
await PersistentAccount.saveAccount({ data: accountData });
// 读取账户数据const result = await PersistentAccount.readAccount();if (result.data) { const account = result.data as UserAccount; console.log('已恢复账户:', account.username);} else { console.log('未找到账户数据');}查看完整文档以获取详细的实现指南和最佳实践。