All Products
Search
Document Center

Mobile Platform as a Service:mPaaS Kotlin Extension

Last Updated:Nov 21, 2023

Integration guide

SDK dependencies

Add dependencies to the build.gradle.kts file of the main project:

 implementation ("com.mpaas.android:mpaas-android-ktx:1.0.0-beta1")

Initialize mPaaS

Scenario 1

If no business logic is required after mPaaS initialization, call mPaaS(this).

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        
        // Initialize mPaas
        mPaaS(this)
    }

}

Scenario 2

If business processing is required after mPaaS is initialized, perform it in the callback.

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        // Initialize mPaas
        mPaaS(this){
            callback { 
            
                //DO something
                Log.i("Framework","mPaaS initialization completed")
            }
        }
    }

}

Scenario 3

If you want to use a new container for mini programs, run the Quick Start command. The mPaaS initialization proceeds as follows:

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        // Initialize mPaas
        mPaaS(this) {
            mriver {
                isAutoInitMriver = true
                mriverInitCallback = object : MriverInitParam.MriverInitCallback {
                    override fun onInit() {
                        TODO("Not yet implemented")
                    }
                    override fun onError(p0: Exception?) {
                        TODO("Not yet implemented")
                    }
                }
            }
            callback {
                //DO something
                Log.i("Framework","mPaaS initialization completed")
            }
        }
    }
}
Important

Please do not filter the process before using the MP.init method. In addition to the main process, initialization code also needs to be executed in the tools and push child processes.