diff --git a/CHANGELOG.md b/CHANGELOG.md index 14617a6..e7715af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,8 @@ All notable changes will be documented in this file. ## [1.0.1] - 2023-01-12 -* Update dependecies. +* Update dependencies. ## [1.0.0] - 2023-01-10 -* Hello World!. \ No newline at end of file +* Hello World!. diff --git a/README.md b/README.md index 9ff5822..38629ab 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ Android SDK for [App Upgrade](https://appupgrade.dev) App Upgrade is a service let your users know when to upgrade your apps or force them to upgrade the app. -[![Twitter](https://img.shields.io/twitter/follow/app_upgrade?style=social)](https://twitter.com/app_upgrade) -[![YouTube](https://img.shields.io/youtube/channel/subscribers/UC0ZVJPYHFVuMwEsro4VZKXw?style=social)](https://www.youtube.com/channel/UC0ZVJPYHFVuMwEsro4VZKXw) +[![](https://jitpack.io/v/appupgrade-dev/app-upgrade-android-sdk.svg)](https://jitpack.io/#appupgrade-dev/app-upgrade-android-sdk) Many times we need to force upgrade mobile apps on users' mobile. Having faced this issue multiple times decided to find a better way to tackle this problem. After doing some research on how people are doing this there are so many custom solutions or checking with the play store or AppStore API if there is a new version available. Although this works if we just want to nudge users that there is a new version available. It doesn't solve the problem where we want to make a decision.. whether it's a soft graceful update or we want to force update. So here is this product that will make developers' life easy. We can set custom messages.. see the versions in beautify dashboard, and many exciting features in the roadmap ahead. @@ -29,7 +28,7 @@ dependencyResolutionManagement { } } ``` -If you are using gradel version prior to 7.x.x add the following in your build.gradle at the end of repositories: +If you are using gradle version prior to 7.x.x add the following in your root build.gradle at the end of repositories: ``` allprojects { repositories { @@ -39,6 +38,16 @@ allprojects { } ``` +For Kotlin build.gradle.kts syntax is: +``` +allprojects { + repositories { + ... + maven ("https://jitpack.io") + } +} +``` + 2. Add the dependency to your project ```groovy dependencies { @@ -46,37 +55,65 @@ dependencies { } ``` +3. Internet Permission required. Add the following in AndroidManifest.xml file if not already present. +``` + +``` + ## How to use it. 1. Register on App Upgrade and follow the instructions to create project and get the x-api-key. 2. Use the SDK. #### Kotlin +Add the following code in your MainActivity.kt -> onCreate method. ```kotlin -val xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5" - -val appInfo = AppInfo( - appId = "com.android.com", - appName = "Wallpaper app", - appVersion = "1.0.0", - platform = "android", - environment = "production" - appLanguage = "es" // Optional, used for localizing the update message. -) - -//Optional -val alertDialogConfig = AlertDialogConfig( - title: "Update Required", //Default: Please Update - updateButtonTitle: "Update Now", //Default: Update Now - laterButtonTitle: "Not Now" //Default: Later -) - -appUpgrade = AppUpgrade() -appUpgrade.checkForUpdates(this, xApiKey, appInfo, alertDialogConfig) +class MainActivity : AppCompatActivity() { + + private lateinit var appUpgrade: AppUpgrade + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + // App Upgrade + val xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5" + + val appInfo = AppInfo( + appId = "com.android.com", + appName = "Wallpaper app", + appVersion = "1.0.0", + platform = "android", + environment = "production", + appLanguage = "es" + ) + + //Optional + val alertDialogConfig = AlertDialogConfig( + title = "Update Required", //Default: Please Update + updateButtonTitle = "Update Now", //Default: Update Now + laterButtonTitle = "Not Now" //Default: Later + ) + + val appUpgrade = AppUpgrade() + appUpgrade.checkForUpdates(this, xApiKey, appInfom alertDialogConfig) + + // appUpgrade.checkForUpdates(this, xApiKey, appInfom) + } +} ``` #### Java +Add the following code in your MainActivity.java -> onCreate method. ```java +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + // App Upgrade String xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5"; String appId = "com.android.com"; @@ -84,23 +121,29 @@ appUpgrade.checkForUpdates(this, xApiKey, appInfo, alertDialogConfig) String appVersion = "1.0.0"; String platform = "android"; String environment = "production"; - String appLanguage = "es" + String appLanguage = "es"; AppInfo appInfo = new AppInfo(appId, appName, appVersion, platform, environment); - String title = "Update Required"; + // Optional + String title = "Update Required."; String updateButtonTitle = "UPDATE"; String laterButtonTitle = "Not Now"; - AlertDialogConfig alertDialogConfig = new AlertDialogConfig(title, updateButtonTitle, laterButtonTitle); AppUpgrade appUpgrade = new AppUpgrade(); appUpgrade.checkForUpdates(this, xApiKey, appInfo, alertDialogConfig); + + // appUpgrade.checkForUpdates(this, xApiKey, appInfo); + } +} ``` ### Note: -2. For opening the app store or play store the app should be live. -3. It might not be able to open the app store or play store in simulator. You can try it in physical device. +1. For opening the app store or play store the app should be live. +2. It might not be able to open the app store or play store in simulator. You can try it in physical device. +3. You can find a sample Kotlin app from here [app-upgrade-android-kotlin-demo-app](https://github.com/appupgrade-dev/app_upgrade_android_kotlin_demo_app) and a sample Java app from here [app-upgrade-android-java-demo-app](https://github.com/appupgrade-dev/app_upgrade_android_java_demo_app) +4. Read detailed blog on how to integrate Kotlin app from here [How to upgrade/force upgrade Android Kotlin app](https://appupgrade.dev/blog/how-to-force-upgrade-android-kotlin-app) and Java app from here [How to upgrade/force upgrade Android Java app](https://appupgrade.dev/blog/how-to-force-upgrade-android-java-app) ## Screenshot diff --git a/app-upgrade-android-sdk/build.gradle b/app-upgrade-android-sdk/build.gradle index 70ae501..837a287 100644 --- a/app-upgrade-android-sdk/build.gradle +++ b/app-upgrade-android-sdk/build.gradle @@ -48,7 +48,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.5.1' - implementation 'com.google.android.material:material:1.7.0' + implementation 'com.google.android.material:material:1.6.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.4' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' @@ -66,4 +66,4 @@ afterEvaluate { } } } -} \ No newline at end of file +} diff --git a/app/build.gradle b/app/build.gradle index 370552e..64b11e5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,11 +35,10 @@ dependencies { implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.5.1' - implementation 'com.google.android.material:material:1.7.0' + implementation 'com.google.android.material:material:1.6.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation project(path: ':app-upgrade-android-sdk') - implementation project(path: ':app-upgrade-android-sdk') testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' -} \ No newline at end of file +}