Skip to content

Commit ae7c973

Browse files
authored
allow for custom app version to be set (#397)
* add custom app version * gitignore
1 parent 221d0a7 commit ae7c973

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,4 @@ captures/
182182
## CUSTOM
183183

184184
Release/
185+
*/out.map

AndroidSDKCore/src/main/java/com/leanplum/Leanplum.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public class Leanplum {
102102
private static RegisterDeviceFinishedCallback registerDeviceFinishedHandler;
103103
private static LeanplumDeviceIdMode deviceIdMode = LeanplumDeviceIdMode.MD5_MAC_ADDRESS;
104104
private static String customDeviceId;
105+
private static String customAppVersion = null;
105106
private static boolean userSpecifiedDeviceId;
106107
private static boolean initializedMessageTemplates = false;
107108
private static boolean locationCollectionEnabled = true;
@@ -281,6 +282,16 @@ public static boolean isScreenTrackingEnabled() {
281282
return LeanplumInternal.getIsScreenTrackingEnabled();
282283
}
283284

285+
/**
286+
* By default, Leanplum reports the version of your app using
287+
* getPackageManager().getPackageInfo, which can be used for reporting and targeting
288+
* on the Leanplum dashboard. If you wish to use any other string as the version,
289+
* you can call this before your call to Leanplum.start()
290+
*/
291+
public static void setAppVersion(String appVersion) {
292+
customAppVersion = appVersion;
293+
}
294+
284295
/**
285296
* Sets the type of device ID to use. Default: {@link LeanplumDeviceIdMode#MD5_MAC_ADDRESS}
286297
*/
@@ -634,6 +645,9 @@ private static void startHelper(
634645

635646
// Setup parameters.
636647
String versionName = Util.getVersionName();
648+
if (customAppVersion != null) {
649+
versionName = customAppVersion;
650+
}
637651
if (versionName == null) {
638652
versionName = "";
639653
}

0 commit comments

Comments
 (0)