Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.mohappsdev:InAppUpdate:v1.1.0'
}
Create ForceUpdateActivity
Modify your MainActivity
IMPORTANT: Specify your settings in Config
button_in_app_update will be shown on main activity when there is an update available and when user taps it update dialog will be shown (Flexible update)
ForceUpdateActivity will be opened when update version meets the settings you have specified and update dialog will be shown and user has to update to use app (Immediate update)
To use this strategy you have to specify a positive number for FORCE_UPDATE_LAST_DIGIT (no limit on digits) and uncomment this line
FORCE_UPDATE_STRATEGY_LIST.add(ForceUpdateStrategy.LAST_DIGIT);
example: If you set it as 4, updates with version code of *4 such as 4, 14, 24, 34, ..., 104, 114, ... will be forced to users
example: If you set it as 23, updates with version code of *23 such as 23, 123, 223, 323, ..., 1023, 1123, ... will be forced to users
this strategy allows you to force update to all your users, all you have to do is make your new update's version number end with your specified number
To use this strategy you have to specify a positive number for FORCE_UPDATE_MAJOR_LENGTH (no limit on digits) and uncomment this line
FORCE_UPDATE_STRATEGY_LIST.add(ForceUpdateStrategy.MAJOR_CHANGE);
example: If you set it as 1, updates where 1 digit from left chenged such as 1 to 2, 12 to 22, 100658 to 200033 will be forced to users
example: If you set it as 2, updates where 2 digits from left chenged such as 11 to 22, 120 to 230, 100658 to 210033 will be forced to users
example: updates where version's length increased such as 9 to 10, 99 to 100 will be forced to users
Copyright 2020 mohapps
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.