Skip to content

Commit

Permalink
Add support for custom attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
appupgrade-dev committed Aug 20, 2023
1 parent f3f8477 commit 9dd01e9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes will be documented in this file.

## [1.0.5] - 2023-08-20

* Add support for custom attributes.

## [1.0.4] - 2023-02-27

* Add support for Amazon, Huawei and other android marketplaces.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 App Upgrade
Copyright (c) 2022-2023 App Upgrade

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
params["app_language"] = appInfo.appLanguage
}

appInfo.customAttributes?.let { customAttributes ->
for ((key, value) in customAttributes) {
params[key] = value.toString()
}
}

val call = appUpgradeApi.versionCheck(xApiKey, params)

call.enqueue(object : Callback<AppUpgradeResponse> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ data class AppInfo(
val appLanguage: String? = null,
val preferredAndroidMarket: String? = null,
val otherAndroidMarketUrl: String? = null,
val customAttributes: Map<String, Any>? = null
) {
constructor(
appId: String,
appName: String,
appVersion: String,
platform: String,
environment: String,
): this(appId, appName, appVersion, platform, environment, null, null, null)
customAttributes: Map<String, Any>? = null
) : this(appId, appName, appVersion, platform, environment, null, null, null, customAttributes)

constructor(
appId: String,
Expand All @@ -25,7 +27,8 @@ data class AppInfo(
platform: String,
environment: String,
appLanguage: String,
): this(appId, appName, appVersion, platform, environment, appLanguage, null, null)
customAttributes: Map<String, Any>? = null
) : this(appId, appName, appVersion, platform, environment, appLanguage, null, null, customAttributes)

constructor(
appId: String,
Expand All @@ -35,5 +38,6 @@ data class AppInfo(
environment: String,
appLanguage: String,
preferredAndroidMarket: String?,
): this(appId, appName, appVersion, platform, environment, appLanguage, preferredAndroidMarket, null)
}
customAttributes: Map<String, Any>? = null
) : this(appId, appName, appVersion, platform, environment, appLanguage, preferredAndroidMarket, null, customAttributes)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class MainActivity : AppCompatActivity() {
appLanguage = "en",
// preferredAndroidMarket = PreferredAndroidMarket.HUAWEI, // or PreferredAndroidMarket.AMAZON or PreferredAndroidMarket.OTHER If not provided default is Google playstore. Optional
// otherAndroidMarketUrl = "https://otherandroidmarketurl.com/app/id" // Required if preferredAndroidMarket is OTHER.
// customAttributes = mapOf(
// "os" to 12,
// "country" to "IN",
// "build" to 100
// )
)

AppUpgrade().checkForUpdates(this, xApiKey, appInfo);
Expand Down

0 comments on commit 9dd01e9

Please sign in to comment.