アプリ内購入をKMPアプリに追加
AdaptyのKMP SDKを使用して、iOSとAndroidにアプリ内購入を統合。レシート処理、サブスクリプション状態の追跡、バックエンド構築の不要化を実現。すべての機能を1つの統合で。
import com.adapty.kmp.Adapty
import com.adapty.kmp.models.AdaptyConfig
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.build()
Adapty.activate(configuration = config)
.onSuccess {
Log.d("Adapty", "SDK initialised")
}
.onError { error ->
Log.e("Adapty", "Adapty init error: ${error.message}")
}
KMPのアプリ内購入にバックエンドは不要
AdaptyのSDKが通常サーバー側で必要な処理をすべて担当:レシート検証、購読状態、更新、トライアル、払い戻しなど。一度接続するだけで、iOSとAndroidで動作するKMPアプリ内購入設定が利用可能。
デモを予約なぜAdapty SDKを選ぶのか?
プラットフォームを超えてサブスクリプションを追跡
iOSとAndroidの両方でユーザーの購読状態を常に把握可能。
バックエンドでのレシート検証
Adaptyが検証を自動で処理するため、自前の構築は不要。
あらゆるサブスクリプション状態を処理
無料トライアル、アップグレード、プロモーション、ファミリー共有、更新などを網羅。
エンタープライズレベルの基盤でスケール
頻繁なアップデート、安定したSDK、99.99%以上のSLAで運用。
プラットフォーム設定
Adapty SDKのインストール
await adapty.activate( 'PUBLIC_SDK_KEY', { customerUserId: 'YOUR_USER_ID', });
購入イベントの処理
KMPのIAPを処理する5つのSDKメソッドを使用
import com.adapty.kmp.Adapty
import com.adapty.kmp.models.AdaptyPurchaseResult
Adapty.makePurchase(product = product).onSuccess { purchaseResult ->
when (purchaseResult) {
is AdaptyPurchaseResult.Success -> {
val profile = purchaseResult.profile
if (profile.accessLevels["YOUR_ACCESS_LEVEL"]?.isActive == true) {
// Grant access to the paid features
}
}
is AdaptyPurchaseResult.UserCanceled -> {
// Handle the case where the user canceled the purchase
}
is AdaptyPurchaseResult.Pending -> {
// Handle deferred purchases (e.g., the user will pay offline with cash)
}
}
}.onError { error ->
// Handle the error
}
import com.adapty.kmp.Adapty
Adapty.restorePurchases().onSuccess { profile ->
if (profile.accessLevels["YOUR_ACCESS_LEVEL"]?.isActive == true) {
// successful access restore
}
}.onError { error ->
// handle the error
}
import com.adapty.kmp.Adapty
Adapty.identify("YOUR_USER_ID") // Unique for each user
.onSuccess {
// successful identify
}
.onError { error ->
// handle the error
}
import com.adapty.kmp.Adapty
import com.adapty.kmp.models.AdaptyProfile
import com.adapty.kmp.models.AdaptyProfileParameters
val builder = AdaptyProfileParameters.Builder()
.withEmail("[email protected]")
.withPhoneNumber("+18888888888")
.withFirstName("John")
.withLastName("Appleseed")
.withGender(AdaptyProfile.Gender.FEMALE)
.withBirthday(AdaptyProfile.Date(1970, 1, 3))
Adapty.updateProfile(builder.build())
.onSuccess {
// profile updated successfully
}
.onError { error ->
// handle the error
}
import com.adapty.kmp.models.AdaptyProfileParameters
val builder = AdaptyProfileParameters.Builder()
// You can set your own custom attributes:
builder.withCustomAttribute("key1", "value1")
// To remove existing key, use .withRemovedCustomAttribute() method:
builder.withRemovedCustomAttribute("key2")
Adaptyは、インディーから大手パブリッシャーまであらゆるステージのアプリを支えます
アプリを成長させるために必要なすべてがKMP SDKに含まれています



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