Test out the best Paywalls and Welcome pages of your Android Apps with Appflow.ai Visual Constructor
Paywall
The SDK provides a shortcut for displaying paid products. After setting the style in Appflow.ai's , you can display it by call method:
Appflow.showPaywall(context: Context, listener: PaywallListener)
When the user clicks the back button, the paywall will automatically close, you can also actively close the following methods
Appflow.closePaywall()
Example
Appflow.showPaywall(context, object : Appflow.PaywallListener {
override fun onPurchaseCompleted(purchase: Purchase) {
Toast.makeText(this@MainActivity, "successful purchase ${purchase.skus}", Toast.LENGTH_SHORT).show()
}
override fun onClose() {}
override fun onFail(msg: String?) {
Toast.makeText(this@MainActivity, "show paywall fail $msg", Toast.LENGTH_LONG).show()
// or
// Appflow.closePaywall()
}
})
API Reference
onPurchaseCompleted(purchase: Purchase)
onPurchaseCompleted(purchase: Purchase)
This method is called when the user closes the paywall
This method will be called when the paywall loading error
WelcomePage
The SDK provides a welcome page that you can add to your application in the following ways
add in layout page
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.imp.page.welcome.WelcomeView
android:id="@+id/welcomeView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
or dynamically add in the code
class SplashActivity : Activity() {
private lateinit var mWelcomeView: WelcomeView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mWelcomeView = WelcomeView(this)
setContentView(mWelcomeView)
}
}
a、 in layout page,add timeOut property
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Set the timeout to 5 seconds -->
<com.imp.page.welcome.WelcomeView
android:id="@+id/welcomeView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:timeOut="5"/>
</FrameLayout>
b、in the code, set by the constructor
class SplashActivity : Activity() {
private lateinit var mWelcomeView: WelcomeView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mWelcomeView = WelcomeView(this, 5)//Set the timeout to 5 seconds
setContentView(mWelcomeView)
}
}
When WelcomePage displays success, failure, or timeout, it will tell you through WelcomeViewListener
WelcomeView.setListener(listener: WelcomeViewListener)
Example
class SplashActivity : AppCompatActivity() {
private lateinit var mWelcomeView: WelcomeView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
mWelcomeView = findViewById(R.id.welcomeView)
mWelcomeView.setListener(object : WelcomeView.WelcomeViewListener {
override fun onShow() {
Handler(Looper.getMainLooper()).postDelayed({ goMain() }, 2000)
}
override fun onFail(t: Throwable) {
goMain()
}
})
}
private fun goMain() {
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
finish()
}
override fun onBackPressed() {}
}
API Reference
Callback when fails or time out