cordova-plugin-ymchat 3.0.0 → 3.2.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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.2.0]
9
+
10
+ ### Added
11
+
12
+ - **`stopVoiceMode()`** — lets the host app programmatically end an active voice call, e.g. when a modal presentation covers the chatbot and the native view-lifecycle callback that would normally stop voice mode doesn't fire. Bridges the native SDKs' `stopVoiceMode()` for the first time (iOS `YMChat` since 2.2.0, Android `YMChatbot-Android` since v3.2.0 — both already pinned since v3.0.0 of this plugin).
13
+
14
+ ## [3.1.0]
15
+
16
+ ### Added
17
+
18
+ - **Activation Mode** — lets the host app open the widget directly into voice mode instead of chat, via `cordova.plugins.ymchat.setActivationMode('voice')` (or `'chat'`, the default). Bridges the native SDKs' `activationMode` config for the first time (iOS `YMChat` since 2.1.0, Android `YMChatbot-Android` since v3.1.0 — both already pinned since v3.0.0 of this plugin).
19
+
8
20
  ## [3.0.0]
9
21
 
10
22
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-ymchat",
3
- "version": "3.0.0",
3
+ "version": "3.2.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="3.0.0"
2
+ <plugin id="cordova-plugin-ymchat" version="3.2.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>
@@ -56,6 +56,9 @@ public class YmChatCordova extends CordovaPlugin {
56
56
  case "closeBot":
57
57
  closeBot();
58
58
  return true;
59
+ case "stopVoiceMode":
60
+ stopVoiceMode();
61
+ return true;
59
62
  case "unlinkDeviceToken":
60
63
  unlinkDeviceToken(args, callbackContext);
61
64
  return true;
@@ -68,6 +71,9 @@ public class YmChatCordova extends CordovaPlugin {
68
71
  case "setVersion":
69
72
  setVersion(args,callbackContext);
70
73
  return true;
74
+ case "setActivationMode":
75
+ setActivationMode(args, callbackContext);
76
+ return true;
71
77
  case "setStatusBarColor":
72
78
  setStatusBarColor(args,callbackContext);
73
79
  return true;
@@ -201,6 +207,10 @@ public class YmChatCordova extends CordovaPlugin {
201
207
  ymChatService.closeBot();
202
208
  }
203
209
 
210
+ public void stopVoiceMode() {
211
+ ymChatService.stopVoiceMode();
212
+ }
213
+
204
214
  public void reloadBot() {
205
215
  ymChatService.reloadBot();
206
216
  }
@@ -307,6 +317,15 @@ public class YmChatCordova extends CordovaPlugin {
307
317
  }
308
318
  }
309
319
 
320
+ private void setActivationMode(JSONArray args, CallbackContext callbackContext) {
321
+ try {
322
+ String mode = args.getString(0);
323
+ ymChatService.setActivationMode(mode, callbackContext);
324
+ } catch (Exception e) {
325
+ Utils.genericErrorHelper(e, callbackContext);
326
+ }
327
+ }
328
+
310
329
  public void setCustomLoaderURL(JSONArray args, CallbackContext callbackContext) {
311
330
  try {
312
331
  String customUrl = args.getString(0);
@@ -7,6 +7,7 @@ import android.util.Log;
7
7
  import com.yellow.ai.ymchat.utils.Utils;
8
8
  import com.yellowmessenger.ymchat.YMChat;
9
9
  import com.yellowmessenger.ymchat.YMConfig;
10
+ import com.yellowmessenger.ymchat.models.YMActivationMode;
10
11
  import com.yellowmessenger.ymchat.models.YellowCallback;
11
12
  import com.yellowmessenger.ymchat.models.YellowDataCallback;
12
13
  import com.yellowmessenger.ymchat.models.YellowUnreadMessageResponse;
@@ -50,6 +51,10 @@ public class YmChatService {
50
51
  ymChat.closeBot();
51
52
  }
52
53
 
54
+ public void stopVoiceMode() {
55
+ ymChat.stopVoiceMode();
56
+ }
57
+
53
58
  public void reloadBot() {
54
59
  ymChat.reloadBot();
55
60
  }
@@ -198,6 +203,10 @@ public class YmChatService {
198
203
  ymChat.config.version = version;
199
204
  }
200
205
 
206
+ public void setActivationMode(String mode, CallbackContext callbackContext) {
207
+ ymChat.config.activationMode = "voice".equalsIgnoreCase(mode) ? YMActivationMode.VOICE : YMActivationMode.CHAT;
208
+ }
209
+
201
210
  public void setCustomLoaderUrl(String url, CallbackContext callbackContext) {
202
211
  ymChat.config.customLoaderUrl = url;
203
212
  }
package/src/ios/ymchat.m CHANGED
@@ -98,6 +98,11 @@
98
98
  [[YMChat shared] closeBot];
99
99
  }
100
100
 
101
+ - (void)stopVoiceMode:(CDVInvokedUrlCommand*)command
102
+ {
103
+ [[YMChat shared] stopVoiceMode];
104
+ }
105
+
101
106
  - (void)reloadBot:(CDVInvokedUrlCommand*)command
102
107
  {
103
108
  [[YMChat shared] reloadBotAndReturnError:nil];
@@ -136,6 +141,13 @@
136
141
  YMChat.shared.config.version = version.integerValue;
137
142
  }
138
143
 
144
+ - (void)setActivationMode:(CDVInvokedUrlCommand*)command
145
+ {
146
+ NSString* mode = [command.arguments objectAtIndex:0];
147
+ assert(YMChat.shared.config != nil);
148
+ YMChat.shared.config.activationMode = [mode isEqualToString:@"voice"] ? YMActivationModeVoice : YMActivationModeChat;
149
+ }
150
+
139
151
  - (void) unlinkDeviceToken:(CDVInvokedUrlCommand*)command {
140
152
  if(YMChat.shared.config) {
141
153
  NSString* apiKey = [command.arguments objectAtIndex:0];
package/www/ymchat.js CHANGED
@@ -38,6 +38,9 @@ const YmChatAPI = {
38
38
  closeBot: () => {
39
39
  exec(null, null, "ymchat", "closeBot", []);
40
40
  },
41
+ stopVoiceMode: () => {
42
+ exec(null, null, "ymchat", "stopVoiceMode", []);
43
+ },
41
44
  unlinkDeviceToken: (apiKey, success, failure) => {
42
45
  exec(success, failure, "ymchat", "unlinkDeviceToken", [apiKey])
43
46
  },
@@ -50,6 +53,9 @@ const YmChatAPI = {
50
53
  setVersion: (version) => {
51
54
  exec(null, null, "ymchat", "setVersion", [version])
52
55
  },
56
+ setActivationMode: (mode) => {
57
+ exec(null, null, "ymchat", "setActivationMode", [mode]);
58
+ },
53
59
  setCustomLoaderURL: (url) => {
54
60
  exec(null, null, "ymchat", "setCustomLoaderURL", [url]);
55
61
  },