cordova-plugin-ymchat 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-ymchat",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Cordova plugin to integrate yellow.ai chatbot",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-ymchat",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-ymchat" version="2.7.0"
2
+ <plugin id="cordova-plugin-ymchat" version="2.8.0"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
  <name>ymchat</name>
@@ -34,7 +34,7 @@
34
34
  <source url="https://github.com/CocoaPods/Specs.git" branch="master"/>
35
35
  </config>
36
36
  <pods use-frameworks="true">
37
- <pod name="YMChat" spec="~> 1.12" swift-version="5.0"/>
37
+ <pod name="YMChat" spec="~> 1.13" swift-version="5.0"/>
38
38
  </pods>
39
39
  </podspec>
40
40
  <config-file parent="/*" target="config.xml">
@@ -24,5 +24,5 @@ repositories {
24
24
  dependencies {
25
25
  implementation 'androidx.appcompat:appcompat:1.0.2'
26
26
  implementation 'androidx.annotation:annotation:1.0.2'
27
- implementation 'com.github.yellowmessenger:YMChatbot-Android:v2.7.+'
27
+ implementation 'com.github.yellowmessenger:YMChatbot-Android:v2.8.+'
28
28
  }
@@ -89,6 +89,12 @@ public class YmChatCordova extends CordovaPlugin {
89
89
  case "setMicBackgroundColor":
90
90
  setMicBackgroundColor(args, callbackContext);
91
91
  return true;
92
+ case "useSecureYmAuth":
93
+ useSecureYmAuth(args,callbackContext);
94
+ return true;
95
+ case "revalidateToken":
96
+ revalidateToken(args,callbackContext);
97
+ return true;
92
98
  }
93
99
  return false;
94
100
  }
@@ -284,4 +290,23 @@ public class YmChatCordova extends CordovaPlugin {
284
290
  Utils.genericErrorHelper(e, callbackContext);
285
291
  }
286
292
  }
293
+
294
+ private void useSecureYmAuth(JSONArray args, CallbackContext callbackContext) {
295
+ try {
296
+ boolean shouldUseSecureYmAuth = args.getBoolean(0);
297
+ ymChatService.useSecureYmAuth(shouldUseSecureYmAuth, callbackContext);
298
+ } catch (Exception e) {
299
+ Utils.genericErrorHelper(e, callbackContext);
300
+ }
301
+ }
302
+
303
+ private void revalidateToken(JSONArray args, CallbackContext callbackContext) {
304
+ try {
305
+ String token = args.getString(0);
306
+ boolean refreshSession = args.getBoolean(1);
307
+ ymChatService.revalidateToken(token, refreshSession, callbackContext);
308
+ } catch (Exception e) {
309
+ Utils.genericErrorHelper(e, callbackContext);
310
+ }
311
+ }
287
312
  }
@@ -23,7 +23,7 @@ public class YmChatService {
23
23
  final String Tag = "YmChat";
24
24
  final String ExceptionString = "Exception";
25
25
  final String code = "code";
26
- final String data = "date";
26
+ final String data = "data";
27
27
 
28
28
  HashMap<String, Object> payloadData = new HashMap<>();
29
29
 
@@ -88,7 +88,15 @@ public class YmChatService {
88
88
  JSONObject jsonObject = new JSONObject();
89
89
  try {
90
90
  jsonObject.put(code, botEvent.getCode());
91
- jsonObject.put(data, new JSONObject(botEvent.getData()));
91
+ JSONObject dataJsonObject = new JSONObject();
92
+ if (botEvent.getData() != null) {
93
+ try {
94
+ dataJsonObject = new JSONObject(botEvent.getData());
95
+ }catch(Exception e) {
96
+ Log.e(Tag, ExceptionString, e);
97
+ }
98
+ }
99
+ jsonObject.put(data, dataJsonObject);
92
100
  PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObject);
93
101
  result.setKeepCallback(true);
94
102
  callback.sendPluginResult(result);
@@ -203,4 +211,16 @@ public class YmChatService {
203
211
  public void setMicBackgroundColor(String color, CallbackContext callbackContext) {
204
212
  ymChat.config.enableSpeechConfig.fabBackgroundColor = color;
205
213
  }
214
+
215
+ public void useSecureYmAuth(boolean shouldUseSecureYmAuth, CallbackContext callbackContext) {
216
+ ymChat.config.useSecureYmAuth = shouldUseSecureYmAuth;
217
+ }
218
+
219
+ public void revalidateToken(String token, boolean refreshSession, CallbackContext callbackContext) {
220
+ try {
221
+ ymChat.revalidateToken(token, refreshSession);
222
+ } catch (Exception e) {
223
+ e.printStackTrace();
224
+ }
225
+ }
206
226
  }
package/src/ios/ymchat.m CHANGED
@@ -94,7 +94,7 @@
94
94
 
95
95
  - (void)reloadBot:(CDVInvokedUrlCommand*)command
96
96
  {
97
- [[YMChat shared] reloadBot];
97
+ [[YMChat shared] reloadBotAndReturnError:nil];
98
98
  }
99
99
 
100
100
  - (void)onEventFromBotWithResponse:(YMBotEventResponse *)response {
@@ -228,6 +228,20 @@
228
228
  YMChat.shared.config.enableSpeechConfig.fabBackgroundColor = [self getColorFromHexString:color];
229
229
  }
230
230
 
231
+ - (void)useSecureYmAuth:(CDVInvokedUrlCommand*)command
232
+ {
233
+ BOOL shouldUseSecureYmAuth = [command.arguments objectAtIndex:0];
234
+ assert(YMChat.shared.config != nil);
235
+ YMChat.shared.config.useSecureYmAuth = shouldUseSecureYmAuth;
236
+ }
237
+
238
+ - (void)revalidateToken:(CDVInvokedUrlCommand*)command
239
+ {
240
+ NSString* token = [command.arguments objectAtIndex:0];
241
+ BOOL refreshSession = [command.arguments objectAtIndex:1];
242
+ [[YMChat shared] revalidateTokenWithToken:token refreshSession:refreshSession error:nil];
243
+ }
244
+
231
245
  - (UIColor *)getColorFromHexString:(NSString *)hexString {
232
246
  unsigned rgbValue = 0;
233
247
  NSScanner *scanner = [NSScanner scannerWithString:hexString];
package/www/ymchat.js CHANGED
@@ -71,6 +71,12 @@ const YmChatAPI = {
71
71
  setMicBackgroundColor: (color) => {
72
72
  exec(null, null, "ymchat", "setMicBackgroundColor", [color]);
73
73
  },
74
+ useSecureYmAuth: (shouldUseSecureYmAuth) => {
75
+ exec(null, null, "ymchat", "useSecureYmAuth", [shouldUseSecureYmAuth]);
76
+ },
77
+ revalidateToken: (token, refreshSession) => {
78
+ exec(null, null, "ymchat", "revalidateToken", [token, refreshSession]);
79
+ }
74
80
  };
75
81
 
76
82
  module.exports = YmChatAPI;