アプリ内購入をCapacitorアプリに追加
AdaptyのCapacitor SDKを使用して、iOSとAndroidにアプリ内購入を統合。レシート処理、サブスクリプション状態の追跡、バックエンド構築の不要化を実現。すべての機能を1つの統合で。
import { adapty } from '@adapty/capacitor';
try {
await adapty.activate({
apiKey: 'YOUR_PUBLIC_SDK_KEY',
params: {
logLevel: 'verbose',
__ignoreActivationOnFastRefresh: true,
}
});
console.log('Adapty activated successfully!');
} catch (error) {
console.error('Failed to activate Adapty SDK:', error);
}
Capacitorのアプリ内購入にバックエンドは不要
AdaptyのSDKが通常サーバー側で必要な処理をすべて担当:レシート検証、購読状態、更新、トライアル、払い戻しなど。一度接続するだけで、iOSとAndroidで動作するCapacitorアプリ内購入設定が利用可能。
デモを予約なぜAdapty SDKを選ぶのか?
プラットフォームを超えてサブスクリプションを追跡
iOSとAndroidの両方でユーザーの購読状態を常に把握可能。
バックエンドでのレシート検証
Adaptyが検証を自動で処理するため、自前の構築は不要。
あらゆるサブスクリプション状態を処理
無料トライアル、アップグレード、プロモーション、ファミリー共有、更新などを網羅。
エンタープライズレベルの基盤でスケール
頻繁なアップデート、安定したSDK、99.99%以上のSLAで運用。
プラットフォーム設定
Adapty SDKのインストール
await adapty.activate( 'PUBLIC_SDK_KEY', { customerUserId: 'YOUR_USER_ID', });
購入イベントの処理
Capacitor向けの簡単統合
数時間でAdapty SDKをセットアップし、iOSとAndroidのアプリ内購入を開始。サポートが必要?完全版Capacitor IAPチュートリアルをご覧ください。
CapacitorのIAPを処理する5つのSDKメソッドを使用
import { adapty } from '@adapty/capacitor';
try {
const result = await adapty.makePurchase({ product });
if (result.type === 'success') {
const isSubscribed = result.profile?.accessLevels['YOUR_ACCESS_LEVEL']?.isActive;
if (isSubscribed) {
// Grant access to the paid features
console.log('User is now subscribed!');
}
} else if (result.type === 'user_cancelled') {
console.log('Purchase cancelled by user');
} else if (result.type === 'pending') {
console.log('Purchase is pending');
}
} catch (error) {
console.error('Purchase failed:', error);
}
import { adapty } from '@adapty/capacitor';
try {
const profile = await adapty.restorePurchases();
const isSubscribed = profile.accessLevels['YOUR_ACCESS_LEVEL']?.isActive;
if (isSubscribed) {
// Restore access to paid features
console.log('Access restored successfully!');
} else {
console.log('No active subscriptions found');
}
} catch (error) {
console.error('Failed to restore purchases:', error);
}
import { adapty } from '@adapty/capacitor';
try {
await adapty.identify({ customerUserId: "YOUR_USER_ID" });
// successfully identified
} catch (error) {
// handle the error
}
import { adapty } from '@adapty/capacitor';
const params = {
email: '[email protected]',
phoneNumber: '+18888888888',
firstName: 'John',
lastName: 'Appleseed',
gender: 'other',
birthday: new Date().toISOString(),
};
try {
await adapty.updateProfile(params);
console.log('Profile updated successfully');
} catch (error) {
console.error('Failed to update profile:', error);
}
import { adapty } from '@adapty/capacitor';
try {
await adapty.updateProfile({
codableCustomAttributes: {
key_1: 'value_1',
key_2: 2,
key_3: null, // to remove keys, pass null as their values
},
});
console.log('Custom attributes updated successfully');
} catch (error) {
console.error('Failed to update custom attributes:', error);
}
Adaptyはインディーから大手パブリッシャーまで、あらゆる段階のアプリを支えます
アプリを成長させるために必要なすべてがCapacitor SDKに含まれています



ノーコード ペイウォールビルダー
iOS、Android、React Native、Flutter、FlutterFlow、KMP、Capacitor用の美しいネイティブペイウォールを開発チームなしで作成。
数分でペイウォールを作成