Android 6.+ migration guide
Upgrading version
Increase the dependency version in your app build.gradle file to upgrade your Qonversion SDK to the latest version
dependencies {
implementation 'io.qonversion.android.sdk:sdk:6.+'
}
Renamings
In this major version, we have renamed several entities, public methods and changed some packages to make our namings and structure more clear. To make everything work just change all the occurrences from the left column of the table below to the new ones.
Before upgrade | After upgrade |
---|---|
QUserProperty | QUserPropertyKey |
setUserProperty | setCustomUserProperty |
setProperty | setUserProperty |
com.qonversion.android.sdk.dto.QUserProperty | com.qonversion.android.sdk.dto.properties.QUserPropertyKey |
com.qonversion.android.sdk.dto.QEntitlement | com.qonversion.android.sdk.dto.entitlements.QEntitlement |
com.qonversion.android.sdk.dto.QEntitlementRenewState | com.qonversion.android.sdk.dto.entitlements.QEntitlementRenewState |
com.qonversion.android.sdk.dto.QEntitlementSource | com.qonversion.android.sdk.dto.entitlements.QEntitlementSource |
com.qonversion.android.sdk.dto.QEntitlementsCacheLifetime | com.qonversion.android.sdk.dto.entitlements.QEntitlementsCacheLifetime |
User properties changes
As mentioned above, we have renamed the QUserProperty
enum to QUserPropertyKey
. It was made to release the name QUserProperty
for a class, containing both the property key and its value. This class will be used in the new Qonversion method userProperties
, which will return all the properties set for the current user.
Qonversion.getSharedInstance().userProperties(new QonversionUserPropertiesCallback() {
@Override
public void onSuccess(@NonNull QUserProperties userProperties) {
for (QUserProperty property : userProperties.getProperties()) {
Log.d("User property", "Key: " + property.getKey() +
", value: " + property.getValue());
}
}
@Override
public void onError(@NonNull QonversionError error) {
// handle error here
}
});
Qonversion.shared.userProperties(object : QonversionUserPropertiesCallback {
override fun onSuccess(userProperties: QUserProperties) {
userProperties.properties.forEach {
Log.d("User property", "key: ${it.key}, value: ${it.value}")
}
}
override fun onError(error: QonversionError) {
// handle error here
}
})
QUserProperties
class returned as the successful result of userProperties
contains several useful fields and methods to get all the types of properties you may want:
Field | Description |
---|---|
properties | List of all user properties |
definedProperties | Subset of all user properties, which were set using Qonversion-defined keys |
customProperties | Subset of all user properties, which were set using custom keys |
flatPropertiesMap | A flattened version of all user properties as a key-value map |
flatDefinedPropertiesMap | A flattened version of defined user properties as a key-value map |
flatCustomPropertiesMap | A flattened version of custom user properties as a key-value map |
Method | Arguments | Description |
---|---|---|
getProperty | key - string | Searches for a property with the given property key in all properties list |
getDefinedProperty | key - QUserPropertyKey | Searches for a property with the given Qonversion-defined property key in the defined properties list. |
The last change here is that we've enriched QUserPropertyKey
enum with several values:
- added a new property key
AdvertisingID
, which is used on iOS but can be received on Android due to cross-platform user management; - added a
Custom
key to represent all the custom properties.
Updated over 1 year ago