Check for Auto Update Preference

The getIsAutoUpdateEnabled method is an asynchronous method that returns a boolean value representing the device user's preference for automatic updates of the Host App.

Kotlin
fun getIsAutoUpdateEnabled(): Boolean?

For this method, DT returns the following values:

RESPONSE
DESCRIPTION

true

User has opted in for automatic updates of the Host App.

false

User has declined automatic app updates of the Host App. The Host App is responsible for surfacing a UI to encourage the device user to opt in for automatic updates of the Host App.

null

Auto Update preference not set. The Host App is responsible for surfacing a UI to encourage the device user to opt in for automatic updates of the Host App.

Example

Kotlin
kotclass MainActivity : AppCompatActivity(), IConnectionCallback {
    lateinit var igniteService: IIgniteService

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initializeSdk(clientSecret, clientMMPUrl) //clientSecret and MMPUrl are stored somewhere in your app.
        igniteService.connect(this)

        // Call remote function on button click
        findViewById(R.id.userOptInCheckBox).setOnCheckedChangeListener {
            IgniteServiceSdk.setAutoUpdateEnabled(isChecked)
        }

    }

    override fun onConnected() {
        Toast.makeText(applicationContext, "Connected and authenticated with Ignite Service", Toast.LENGTH_SHORT).show()
    }

    override fun onDisconnected(message: String?) {
        Toast.makeText(applicationContext, "Disconnected from Ignite Service: $message", Toast.LENGTH_SHORT).show()
    }

    override fun onDestroy() {
        super.onDestroy()
        igniteService.disconnect(this)
    }
    
    override fun onStart() {
        super.onStart()

        val intentFilter = IntentFilter().apply {
            addAction(IgniteServiceSdk.ACTION_APP_UPDATE_JOB_SCHEDULED)
            addAction(IgniteServiceSdk.ACTION_APP_UPDATE_JOB_CANCELLED)
        }

        registerReceiver(jobStatusBroadcastReceiver, intentFilter)
    }
    
    override fun onStop() {
        super.onStop()

        unregisterReceiver(jobStatusBroadcastReceiver)
    }

    private fun initializeSdk(clientSecret: String = CLIENT_SECRET, clientMMPUrl: String) {
        igniteService = IgniteServiceSdk.init(
            applicationContext,
            clientSecret,
            clientMMPUrl
        )

        if (IgniteServiceSdk.getIsAutoUpdateEnabled() == null) {
            Toast.makeText(this, "No user Opt in value for auto update", Toast.LENGTH_LONG).show()
        } else if (IgniteServiceSdk.getIsAutoUpdateEnabled() == true) {
            checkboxUserOptIn.isChecked = true
        }
    }
    
    private val jobStatusBroadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
        override fun onReceive(context: Context?, intent: Intent) {
            when (intent.action) {
                IgniteServiceSdk.ACTION_APP_UPDATE_JOB_SCHEDULED -> {
                    toast("App Update Job Scheduled.")
                }
                IgniteServiceSdk.ACTION_APP_UPDATE_JOB_CANCELLED -> {
                    toast("App Update Job Cancelled.")
                }
                else -> {
                    println("$TAG Unknown Broadcast Action")
                }
            }
        }
    }

    companion object {
        private const val clientSecret = "my-client-secret-secretly-stored"
    }
}

Last updated