-
-
Save sakshampruthi/42e05a9fc694cc600146e02e5897c8d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
.. | |
forceUpdate = remoteConfig().getBoolean(FORCE_UPDATE) | |
remoteConfig().fetchAndActivate().addOnSuccessListener { | |
checkInAppUpdate() | |
} | |
.. | |
} | |
private fun checkInAppUpdate(){ | |
.. | |
appUpdateManager.startUpdateFlowForResult( | |
appUpdateInfo, | |
if(forceUpdate) AppUpdateType.IMMEDIATE else AppUpdateType.FLEXIBLE, | |
this, | |
IN_APP_UPDATE_REQUEST_CODE | |
) | |
.. | |
} | |
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
when (requestCode) { | |
IN_APP_UPDATE_REQUEST_CODE -> { | |
when(resultCode){ | |
//close the app if user closes immediate update | |
Activity.RESULT_CANCELED -> { | |
if(forceUpdate) finishAffinity() | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment