mPaaS Kotlin extension

Updated at:

Integration guide

SDK dependency

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

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

mPaaS initialization

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

To process business logic after mPaaS initialization, use the callback.

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()

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

}

Scenario 3

If you use the new Mini Program container (see Getting Started), initialize mPaaS 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 complete")
            }
        }
    }
}
Important

Do not filter processes before calling the MP.init method. In addition to the main process, the initialization code must also run in the tools and push child processes.