Skip to content

Commit 6da6143

Browse files
Merge pull request #633 from Kommunicate-io/release_2.14.2
Incremented version to 2.14.2 and Improved appID handling in New Function
2 parents ff3454c + f8c0331 commit 6da6143

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

kommunicate/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ android {
1818
compileSdk 34
1919
targetSdkVersion 35
2020
versionCode 1
21-
versionName "2.14.1"
21+
versionName "2.14.2"
2222
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2323
buildConfigField "String", "KOMMUNICATE_VERSION", "\"" + versionName + "\""
2424
buildConfigField "String", "CHAT_SERVER_URL", '"https://chat.kommunicate.io"'

kommunicate/src/main/java/io/kommunicate/Kommunicate.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public static void launchConversationWithUser(
324324
return;
325325
}
326326

327-
initializeKommunicate(context, resolvedAppId);
327+
boolean isAppIdSame = initializeKommunicate(context, resolvedAppId);
328328

329329
final KmConversationBuilder conversationBuilder =
330330
(kmConversationBuilder != null) ? kmConversationBuilder : new KmConversationBuilder(context);
@@ -352,7 +352,7 @@ public void onFailure(Object error) {
352352
String inputUserId = (kmUser != null) ? kmUser.getUserId() : null;
353353

354354
boolean isSameUser = inputUserId != null && inputUserId.equals(loggedInUserId);
355-
boolean shouldSkipLogin = KMUser.isLoggedIn(context) && (isSameUser || (isVisitorUser && shouldMaintainSession));
355+
boolean shouldSkipLogin = KMUser.isLoggedIn(context) && isAppIdSame && (isSameUser || (isVisitorUser && shouldMaintainSession));
356356

357357
if (shouldSkipLogin) {
358358
proceedAfterLogin.run();
@@ -428,20 +428,27 @@ private static String resolveAppId(String appID, KMUser kmUser) {
428428
return null;
429429
}
430430

431-
private static void initializeKommunicate(Context context, String applicationID) {
431+
private static boolean initializeKommunicate(Context context, String applicationID) {
432432
try {
433433
String currentAppKey = KommunicateSettings.getInstance(context).getApplicationKey();
434434

435+
boolean isAppIdChanged = !TextUtils.isEmpty(currentAppKey)
436+
&& !PLACEHOLDER_APP_ID.equals(currentAppKey)
437+
&& !applicationID.equals(currentAppKey);
438+
435439
if (TextUtils.isEmpty(currentAppKey) || PLACEHOLDER_APP_ID.equals(currentAppKey)) {
436440
PrefSettings.getInstance(context).setApplicationKey(applicationID);
437441
}
438442

439443
Kommunicate.init(context, applicationID);
444+
445+
return !isAppIdChanged;
440446
} catch (Exception e) {
441447
Utils.printLog(context, TAG, "Failed to initialize Kommunicate: " + e.getMessage());
448+
return true; // Don't block flow even if init fails
442449
}
443450
}
444-
451+
445452
/**
446453
* To Check the Login status & launch the Pre Chat Lead Collection Screen
447454
*

kommunicate/src/main/java/io/kommunicate/devkit/api/conversation/Message.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ public Message(Parcel in) {
144144
topicId = in.readString();
145145
connected = in.readByte() != 0;
146146
contentType = (short) in.readInt();
147-
metadata = in.readHashMap(String.class.getClassLoader());
147+
int metadataSize = in.readInt();
148+
metadata = new HashMap<>();
149+
for (int i = 0; i < metadataSize; i++) {
150+
String key = in.readString();
151+
String value = in.readString();
152+
if (key != null) {
153+
metadata.put(key, value);
154+
}
155+
}
148156
status = (short) in.readInt();
149157
hidden = in.readByte() != 0;
150158
replyMessage = in.readInt();
@@ -896,7 +904,16 @@ public void writeToParcel(Parcel dest, int flags) {
896904
dest.writeString(topicId);
897905
dest.writeByte((byte) (connected ? 1 : 0));
898906
dest.writeInt(contentType);
899-
dest.writeMap(metadata);
907+
// dest.writeMap(metadata);
908+
if (metadata != null) {
909+
dest.writeInt(metadata.size());
910+
for (Map.Entry<String, String> entry : metadata.entrySet()) {
911+
dest.writeString(entry.getKey());
912+
dest.writeString(entry.getValue());
913+
}
914+
} else {
915+
dest.writeInt(0);
916+
}
900917
dest.writeInt(status);
901918
dest.writeByte((byte) (hidden ? 1 : 0));
902919
dest.writeInt(replyMessage);

kommunicateui/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ android {
1616
targetSdkVersion 35
1717
minSdkVersion 21
1818
versionCode 1
19-
versionName "2.14.1"
19+
versionName "2.14.2"
2020
buildToolsVersion = '34.0.0'
2121
consumerProguardFiles 'proguard-rules.txt'
2222
vectorDrawables.useSupportLibrary = true

0 commit comments

Comments
 (0)