Android SDK available:
https://pub.dev/packages/linkfive_purchases
Add the SDK to your flutter app:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.LinkFive:android-purchases-sdk:VERSION'
}
Initialize the SDK
LinkFivePurchases.init(apiKey = "LinkFive Api Key");
fetch all available subscriptions:
LinkFivePurchases.fetchSubscriptions(context = this);
LinkFive uses LiveData to pass data to your application. You can either just use the stream or use a StreamBuilder
LinkFivePurchases.linkFiveSubscriptionLiveData().observe(this, subscriptionDataObserver)
val subscriptionDataObserver = Observer<LinkFiveSubscriptionData> { data: LinkFiveSubscriptionData ->
// Update the UI.
buildSubscription(data)
}
Just call purchase including the sku
LinkFivePurchases.purchase(skuDetail.skuDetails.sku, this)
You will receive the data through the active subscription LiveData.
LinkFivePurchases.linkFiveActivePurchasesLiveData().observe(this, activeSubscriptionDataObserver)
val activeSubscriptionDataObserver = Observer<LinkFiveVerifiedPurchases> { data: LinkFiveVerifiedPurchases ->
// Update the UI.
handleActiveSubscription(data)
}
There is no need to restore a purchase. The sdk will always load the active subscriptions after initialization.