Skip to content

Commit

Permalink
updated the code in iOS and Android for eu Configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhijeetRanjan308 committed Apr 19, 2024
1 parent 9552704 commit 363ee9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class KmMethodHandler implements MethodCallHandler {
private static final String ERROR = "Error";
private Activity context;
private MethodChannel methodChannel;
private KMServerConfiguration serverConfig = KMServerConfiguration.DEFAULTCONFIGURATION;
public KmMethodHandler(Activity context) {
this.context = context;
}
Expand All @@ -69,13 +68,10 @@ public void onMethodCall(MethodCall call, final Result result) {
try {
String serverConfigText = (String) call.arguments();
if (!TextUtils.isEmpty(serverConfigText)) {
switch (serverConfigText) {
case "euConfiguration":
this.serverConfig = KMServerConfiguration.EUCONFIGURATION;
Kommunicate.setServerConfiguration(context, KMServerConfiguration.DEFAULTCONFIGURATION);
break;
default:
result.error(ERROR, "It only supports `euConfiguration` for now.", null);
if (serverConfigText == "euConfiguration") {
Kommunicate.setServerConfiguration(context, KMServerConfiguration.EUCONFIGURATION);
} else {
Kommunicate.setServerConfiguration(context, KMServerConfiguration.DEFAULTCONFIGURATION);
}
} else {
result.error(ERROR, "Invalid Server Config", null);
Expand All @@ -92,9 +88,6 @@ public void onMethodCall(MethodCall call, final Result result) {
KMUser user = (KMUser) GsonUtils.getObjectFromJson(userObject.toString(), KMUser.class);

if (userObject.has("appId") && !TextUtils.isEmpty(userObject.get("appId").toString())) {
if (serverConfig == KMServerConfiguration.EUCONFIGURATION) {
Kommunicate.setServerConfiguration(context, serverConfig);
}
Kommunicate.init(context, userObject.get("appId").toString());
} else {
result.error(ERROR, "appId is missing", null);
Expand Down Expand Up @@ -180,9 +173,6 @@ public void onFailure(RegistrationResponse registrationResponse, Exception excep
try {
String appId = (String) call.arguments();
if (!TextUtils.isEmpty(appId)) {
if (serverConfig == KMServerConfiguration.EUCONFIGURATION) {
Kommunicate.setServerConfiguration(context, serverConfig);
}
Kommunicate.init(context, appId);
} else {
result.error(ERROR, "appId is missing", null);
Expand Down
23 changes: 4 additions & 19 deletions ios/Classes/SwiftKommunicateFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class SwiftKommunicateFlutterPlugin: NSObject, FlutterPlugin, KMPreChatFo
var conversationTitle: String? = nil;
var conversationInfo: [AnyHashable: Any]? = nil;
var teamId: String? = nil;
var serverConfig: KMServerConfiguration = .defaultConfiguration;
static let KM_CONVERSATION_METADATA: String = "conversationMetadata";
static let CLIENT_CONVERSATION_ID: String = "clientConversationId";
static let CONVERSATION_ID: String = "conversationId";
Expand Down Expand Up @@ -52,12 +51,10 @@ public class SwiftKommunicateFlutterPlugin: NSObject, FlutterPlugin, KMPreChatFo
self.sendErrorResultWithCallback(result: result, message: "Invalid Server Config")
return
}
switch serverConfig {
case "euConfiguration":
self.serverConfig = .euConfiguration
Kommunicate.setServerConfiguration(.euConfiguration)
default:
self.sendErrorResultWithCallback(result: result, message: "It only supports `euConfiguration` for now.")
if (serverConfig == "euConfiguration") {
Kommunicate.setServerConfiguration(.euConfiguration)
} else {
Kommunicate.setServerConfiguration(.defaultConfiguration)
}
} else if(call.method == "isLoggedIn") {
result(Kommunicate.isLoggedIn)
Expand All @@ -71,9 +68,6 @@ public class SwiftKommunicateFlutterPlugin: NSObject, FlutterPlugin, KMPreChatFo
self.sendErrorResultWithCallback(result: result, message: "Invalid or missing appId")
return
}
if serverConfig == .euConfiguration {
Kommunicate.setServerConfiguration(.euConfiguration)
}
Kommunicate.setup(applicationId: appId)
userDict.removeValue(forKey: "appId")

Expand All @@ -100,9 +94,6 @@ public class SwiftKommunicateFlutterPlugin: NSObject, FlutterPlugin, KMPreChatFo
self.sendErrorResultWithCallback(result: result, message: "Invalid or missing appId")
return
}
if serverConfig == .euConfiguration {
Kommunicate.setServerConfiguration(.euConfiguration)
}
Kommunicate.setup(applicationId: appId)
let kmUser = Kommunicate.createVisitorUser()
kmUser.applicationId = appId
Expand Down Expand Up @@ -340,9 +331,6 @@ public class SwiftKommunicateFlutterPlugin: NSObject, FlutterPlugin, KMPreChatFo

self.agentIds = agentIds
self.botIds = botIds
if serverConfig == .euConfiguration {
Kommunicate.setServerConfiguration(.euConfiguration)
}
if Kommunicate.isLoggedIn{
self.handleCreateConversation()
}else{
Expand Down Expand Up @@ -573,9 +561,6 @@ public class SwiftKommunicateFlutterPlugin: NSObject, FlutterPlugin, KMPreChatFo

kmUser.contactNumber = phoneNumber
kmUser.displayName = name
if serverConfig == .euConfiguration {
Kommunicate.setServerConfiguration(.euConfiguration)
}
Kommunicate.setup(applicationId: applicationKey)
Kommunicate.registerUser(kmUser, completion:{
response, error in
Expand Down

0 comments on commit 363ee9b

Please sign in to comment.