Android SDK API Reference
Complete Kotlin API reference for VLPlay SDK for Android. [PLACEHOLDER] The SDK exposes all functionality through the VLPlaySDK singleton object. All callback-based methods also have coroutine-based suspend function equivalents (suffix Async) for Kotlin coroutine projects.
[PLACEHOLDER] Android SDK requires initialization in Application.onCreate(). All UI-related calls (login, purchase, support) require an Activity reference. Non-UI calls (analytics, checking auth state) can be made from any context.
VLPlaySDK
initialize(context: Context, config: VLPlayConfig)
Initialize the SDK. Must be called in Application.onCreate().
version: String
Returns the SDK version string.
isInitialized(): Boolean
Returns true if initialized successfully.
auth
auth.login(activity: Activity, callback: (AuthResult) -> Unit)
Opens the VLPlay login screen. Result is delivered to the callback on the main thread.
sealed class AuthResult {
data class Success(val user: VLPlayUser, val token: VLPlayToken) : AuthResult()
data class Error(val code: Int, val message: String) : AuthResult()
object Cancelled : AuthResult()
}
auth.loginAsync(activity: Activity): AuthResult (suspend)
Coroutine version of login.
auth.logout(callback: (() -> Unit)? = null)
Log out and clear the session.
auth.currentUser: VLPlayUser?
Returns the current user or null.
iap
iap.getProducts(productIds: List<String>, callback: (IAPResult) -> Unit)
Fetch products from Google Play Billing.
iap.purchase(activity: Activity, productId: String, callback: (PurchaseResult) -> Unit)
Initiate a purchase flow.
sealed class PurchaseResult {
data class Success(val transactionId: String, val productId: String) : PurchaseResult()
object Cancelled : PurchaseResult()
data class Error(val code: Int, val message: String) : PurchaseResult()
}
analytics
analytics.track(event: String, properties: Map<String, Any> = emptyMap())
Track a custom event. Fire-and-forget; events are batched internally.
analytics.setUserProperties(properties: Map<String, Any>)
Set persistent user properties.
support
support.show(activity: Activity)
Present the VLPlay support overlay.
support.showNewTicket(activity: Activity, subject: String? = null)
Open new ticket form.
support.getUnreadCountAsync(): Int (suspend)
Returns unread ticket/message count.