import android.app.Application
import com.appactor.android.api.AppActor
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
class MainApplication : Application(), CoroutineScope by MainScope() {
override fun onCreate() {
super.onCreate()
launch {
AppActor.shared.configure(
context = applicationContext,
apiKey = "pk_YOUR_PUBLIC_APP_KEY",
)
}
}
}
// Later, from the purchase screen:
lifecycleScope.launch {
val offerings = AppActor.shared.offerings()
val packageToBuy = offerings.current?.monthly ?: return@launch
val result = AppActor.shared.purchase(activity, packageToBuy)
val info = AppActor.shared.getCustomerInfo()
val isPremium = info.hasActiveEntitlement("premium")
}