cordova-plugin-ymchat 3.2.0 → 3.4.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.4.0]
9
+
10
+ ### Added
11
+
12
+ - **Auto-Sent Initial User Message** — lets the host app automatically send a configured message as soon as the chat widget opens, rendered as a real outgoing user message, via `cordova.plugins.ymchat.setInitialUserMessage('...')`. Bridges the native SDKs' `initialUserMessage` config for the first time (`YMChatbot-Android` since v3.5.0, iOS `YMChat` since 2.4.0 — this plugin now requires those versions or newer).
13
+
14
+ ## [3.3.0]
15
+
16
+ ### Added
17
+
18
+ - **Configurable Upload Sources** (Android only) — restricts the attachment picker to specific sources via `cordova.plugins.ymchat.setAllowedUploadSources(['camera'])` (or `['file']`, or both). Bridges the native Android SDK's `allowedUploadSources` config for the first time (`YMChatbot-Android` since v3.3.0, already pinned since v3.0.0 of this plugin). No iOS equivalent exists natively, so calling this on iOS is a no-op — the plugin doesn't implement the selector there.
19
+
8
20
  ## [3.2.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.2.0",
3
+ "version": "3.4.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.2.0"
2
+ <plugin id="cordova-plugin-ymchat" version="3.4.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>
@@ -33,7 +33,7 @@
33
33
  <source url="https://github.com/CocoaPods/Specs.git" branch="master"/>
34
34
  </config>
35
35
  <pods use-frameworks="true">
36
- <pod name="YMChat" spec="~> 2.3.0" swift-version="5.0"/>
36
+ <pod name="YMChat" spec="~> 2.4.0" swift-version="5.0"/>
37
37
  </pods>
38
38
  </podspec>
39
39
  <config-file parent="/*" target="config.xml">
@@ -23,5 +23,5 @@ repositories {
23
23
  dependencies {
24
24
  implementation 'androidx.appcompat:appcompat:1.0.2'
25
25
  implementation 'androidx.annotation:annotation:1.0.2'
26
- implementation 'com.github.yellowmessenger:YMChatbot-Android:v3.4.0'
26
+ implementation 'com.github.yellowmessenger:YMChatbot-Android:v3.5.0'
27
27
  }
@@ -10,6 +10,9 @@ import org.apache.cordova.CordovaPlugin;
10
10
  import org.json.JSONArray;
11
11
  import org.json.JSONObject;
12
12
 
13
+ import java.util.ArrayList;
14
+ import java.util.List;
15
+
13
16
  public class YmChatCordova extends CordovaPlugin {
14
17
 
15
18
  final String Tag = "YmChat";
@@ -32,6 +35,9 @@ public class YmChatCordova extends CordovaPlugin {
32
35
  case "setAuthenticationToken":
33
36
  setAuthenticationToken(args, callbackContext);
34
37
  return true;
38
+ case "setInitialUserMessage":
39
+ setInitialUserMessage(args, callbackContext);
40
+ return true;
35
41
  case "showCloseButton":
36
42
  showCloseButton(args, callbackContext);
37
43
  return true;
@@ -89,6 +95,9 @@ public class YmChatCordova extends CordovaPlugin {
89
95
  case "useLiteVersion":
90
96
  useLiteVersion(args, callbackContext);
91
97
  return true;
98
+ case "setAllowedUploadSources":
99
+ setAllowedUploadSources(args, callbackContext);
100
+ return true;
92
101
  case "reloadBot":
93
102
  reloadBot();
94
103
  return true;
@@ -153,6 +162,19 @@ public class YmChatCordova extends CordovaPlugin {
153
162
  }
154
163
  }
155
164
 
165
+ private void setAllowedUploadSources(JSONArray args, CallbackContext callbackContext) {
166
+ try {
167
+ JSONArray sourcesArray = args.getJSONArray(0);
168
+ List<String> sources = new ArrayList<>();
169
+ for (int i = 0; i < sourcesArray.length(); i++) {
170
+ sources.add(sourcesArray.getString(i));
171
+ }
172
+ ymChatService.setAllowedUploadSources(sources, callbackContext);
173
+ } catch (Exception e) {
174
+ Utils.genericErrorHelper(e, callbackContext);
175
+ }
176
+ }
177
+
156
178
  private void setDisableActionsOnLoad(JSONArray args, CallbackContext callbackContext) {
157
179
  try {
158
180
  boolean shouldDisableActionsOnLoad = args.getBoolean(0);
@@ -242,6 +264,15 @@ public class YmChatCordova extends CordovaPlugin {
242
264
  }
243
265
  }
244
266
 
267
+ public void setInitialUserMessage(JSONArray args, CallbackContext callbackContext) {
268
+ try {
269
+ String initialUserMessage = args.getString(0);
270
+ ymChatService.setInitialUserMessage(initialUserMessage, callbackContext);
271
+ } catch (Exception e) {
272
+ Utils.genericErrorHelper(e, callbackContext);
273
+ }
274
+ }
275
+
245
276
  public void showCloseButton(JSONArray args, CallbackContext callbackContext) {
246
277
  try {
247
278
  boolean closeButton = args.getBoolean(0);
@@ -8,6 +8,7 @@ import com.yellow.ai.ymchat.utils.Utils;
8
8
  import com.yellowmessenger.ymchat.YMChat;
9
9
  import com.yellowmessenger.ymchat.YMConfig;
10
10
  import com.yellowmessenger.ymchat.models.YMActivationMode;
11
+ import com.yellowmessenger.ymchat.models.YMUploadSource;
11
12
  import com.yellowmessenger.ymchat.models.YellowCallback;
12
13
  import com.yellowmessenger.ymchat.models.YellowDataCallback;
13
14
  import com.yellowmessenger.ymchat.models.YellowUnreadMessageResponse;
@@ -18,7 +19,9 @@ import org.apache.cordova.PluginResult;
18
19
  import org.json.JSONArray;
19
20
  import org.json.JSONObject;
20
21
 
22
+ import java.util.ArrayList;
21
23
  import java.util.HashMap;
24
+ import java.util.List;
22
25
 
23
26
  public class YmChatService {
24
27
  YMChat ymChat;
@@ -71,6 +74,10 @@ public class YmChatService {
71
74
  ymChat.config.ymAuthenticationToken = token;
72
75
  }
73
76
 
77
+ public void setInitialUserMessage(String initialUserMessage, CallbackContext callbackContext) {
78
+ ymChat.config.initialUserMessage = initialUserMessage;
79
+ }
80
+
74
81
  public void showCloseButton(boolean show, CallbackContext callbackContext) {
75
82
  ymChat.config.showCloseButton = show;
76
83
  }
@@ -227,6 +234,14 @@ public class YmChatService {
227
234
  ymChat.config.useLiteVersion = shouldUseLiteVersion;
228
235
  }
229
236
 
237
+ public void setAllowedUploadSources(List<String> sources, CallbackContext callbackContext) {
238
+ List<YMUploadSource> uploadSources = new ArrayList<>();
239
+ for (String source : sources) {
240
+ uploadSources.add(YMUploadSource.valueOf(source.toUpperCase()));
241
+ }
242
+ ymChat.config.allowedUploadSources = uploadSources;
243
+ }
244
+
230
245
  public void setMicIconColor(String color, CallbackContext callbackContext) {
231
246
  ymChat.config.speechConfig.fabIconColor = color;
232
247
  }
package/src/ios/ymchat.m CHANGED
@@ -43,6 +43,13 @@
43
43
  YMChat.shared.config.ymAuthenticationToken = authToken;
44
44
  }
45
45
 
46
+ - (void)setInitialUserMessage:(CDVInvokedUrlCommand*)command
47
+ {
48
+ NSString* initialUserMessage = [command.arguments objectAtIndex:0];
49
+ assert(YMChat.shared.config != nil);
50
+ YMChat.shared.config.initialUserMessage = initialUserMessage;
51
+ }
52
+
46
53
  - (void)showCloseButton:(CDVInvokedUrlCommand*)command
47
54
  {
48
55
  BOOL closeBot = [command.arguments objectAtIndex:0];
package/www/ymchat.js CHANGED
@@ -14,6 +14,9 @@ const YmChatAPI = {
14
14
  setAuthenticationToken: (token) => {
15
15
  exec(null, null, "ymchat", "setAuthenticationToken", [token]);
16
16
  },
17
+ setInitialUserMessage: (message) => {
18
+ exec(null, null, "ymchat", "setInitialUserMessage", [message]);
19
+ },
17
20
  showCloseButton: (closeBot) => {
18
21
  exec(null, null, "ymchat", "showCloseButton", [closeBot]);
19
22
  },
@@ -71,6 +74,9 @@ const YmChatAPI = {
71
74
  useLiteVersion: (shouldUseLiteVersion) => {
72
75
  exec(null, null, "ymchat", "useLiteVersion", [shouldUseLiteVersion]);
73
76
  },
77
+ setAllowedUploadSources: (sources) => {
78
+ exec(null, null, "ymchat", "setAllowedUploadSources", [sources]);
79
+ },
74
80
  reloadBot: () => {
75
81
  exec(null, null, "ymchat", "reloadBot", []);
76
82
  },