cordova-plugin-ymchat 2.8.0 → 2.10.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.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Cordova plugin to integrate yellow.ai chatbot",
|
|
5
5
|
"cordova": {
|
|
6
6
|
"id": "cordova-plugin-ymchat",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"cordova-android",
|
|
19
19
|
"cordova-plugin-ymchat"
|
|
20
20
|
],
|
|
21
|
-
"author": "
|
|
21
|
+
"author": "Sankalp",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"homepage": "https://github.com/yellowmessenger/cordova-plugin-ymchat.git",
|
|
24
24
|
"bugs": {
|
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.
|
|
2
|
+
<plugin id="cordova-plugin-ymchat" version="2.10.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.
|
|
37
|
+
<pod name="YMChat" spec="~> 1.15" swift-version="5.0"/>
|
|
38
38
|
</pods>
|
|
39
39
|
</podspec>
|
|
40
40
|
<config-file parent="/*" target="config.xml">
|
package/src/android/build.gradle
CHANGED
|
@@ -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.
|
|
27
|
+
implementation 'com.github.yellowmessenger:YMChatbot-Android:v2.10.+'
|
|
28
28
|
}
|
|
@@ -95,6 +95,9 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
95
95
|
case "revalidateToken":
|
|
96
96
|
revalidateToken(args,callbackContext);
|
|
97
97
|
return true;
|
|
98
|
+
case "sendEventToBot":
|
|
99
|
+
sendEventToBot(args,callbackContext);
|
|
100
|
+
return true;
|
|
98
101
|
}
|
|
99
102
|
return false;
|
|
100
103
|
}
|
|
@@ -300,6 +303,60 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
300
303
|
}
|
|
301
304
|
}
|
|
302
305
|
|
|
306
|
+
public void setThemeBotName(JSONArray args, CallbackContext callbackContext) {
|
|
307
|
+
try {
|
|
308
|
+
String botName = args.getString(0);
|
|
309
|
+
ymChatService.setThemeBotName(botName, callbackContext);
|
|
310
|
+
} catch (Exception e) {
|
|
311
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
public void setThemeBotDescription(JSONArray args, CallbackContext callbackContext) {
|
|
316
|
+
try {
|
|
317
|
+
String botDesc = args.getString(0);
|
|
318
|
+
ymChatService.setThemeBotDescription(botDesc, callbackContext);
|
|
319
|
+
} catch (Exception e) {
|
|
320
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
public void setThemePrimaryColor(JSONArray args, CallbackContext callbackContext) {
|
|
325
|
+
try {
|
|
326
|
+
String color = args.getString(0);
|
|
327
|
+
ymChatService.setThemePrimaryColor(color, callbackContext);
|
|
328
|
+
} catch (Exception e) {
|
|
329
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
public void setThemeSecondaryColor(JSONArray args, CallbackContext callbackContext) {
|
|
334
|
+
try {
|
|
335
|
+
String color = args.getString(0);
|
|
336
|
+
ymChatService.setThemeSecondaryColor(color, callbackContext);
|
|
337
|
+
} catch (Exception e) {
|
|
338
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
public void setThemeBotIcon(JSONArray args, CallbackContext callbackContext) {
|
|
343
|
+
try {
|
|
344
|
+
String iconUrl = args.getString(0);
|
|
345
|
+
ymChatService.setThemeBotIcon(iconUrl, callbackContext);
|
|
346
|
+
} catch (Exception e) {
|
|
347
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public void setThemeBotClickIcon(JSONArray args, CallbackContext callbackContext) {
|
|
352
|
+
try {
|
|
353
|
+
String iconUrl = args.getString(0);
|
|
354
|
+
ymChatService.setThemeBotClickIcon(iconUrl, callbackContext);
|
|
355
|
+
} catch (Exception e) {
|
|
356
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
303
360
|
private void revalidateToken(JSONArray args, CallbackContext callbackContext) {
|
|
304
361
|
try {
|
|
305
362
|
String token = args.getString(0);
|
|
@@ -309,4 +366,14 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
309
366
|
Utils.genericErrorHelper(e, callbackContext);
|
|
310
367
|
}
|
|
311
368
|
}
|
|
369
|
+
|
|
370
|
+
private void sendEventToBot(JSONArray args, CallbackContext callbackContext) {
|
|
371
|
+
try {
|
|
372
|
+
String code = args.getString(0);
|
|
373
|
+
JSONObject data = args.getJSONObject(1);
|
|
374
|
+
ymChatService.sendEventToBot(code, data, callbackContext);
|
|
375
|
+
} catch (Exception e) {
|
|
376
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
312
379
|
}
|
|
@@ -10,6 +10,7 @@ import com.yellowmessenger.ymchat.YMConfig;
|
|
|
10
10
|
import com.yellowmessenger.ymchat.models.YellowCallback;
|
|
11
11
|
import com.yellowmessenger.ymchat.models.YellowDataCallback;
|
|
12
12
|
import com.yellowmessenger.ymchat.models.YellowUnreadMessageResponse;
|
|
13
|
+
import com.yellowmessenger.ymchat.models.YMEventModel;
|
|
13
14
|
|
|
14
15
|
import org.apache.cordova.CallbackContext;
|
|
15
16
|
import org.apache.cordova.PluginResult;
|
|
@@ -216,6 +217,30 @@ public class YmChatService {
|
|
|
216
217
|
ymChat.config.useSecureYmAuth = shouldUseSecureYmAuth;
|
|
217
218
|
}
|
|
218
219
|
|
|
220
|
+
public void setThemeBotName(String name, CallbackContext callbackContext) {
|
|
221
|
+
ymChat.config.theme.botName = name;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public void setThemeBotDescription(String description, CallbackContext callbackContext) {
|
|
225
|
+
ymChat.config.theme.botDesc = description;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public void setThemePrimaryColor(String color, CallbackContext callbackContext) {
|
|
229
|
+
ymChat.config.theme.primaryColor = color;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public void setThemeSecondaryColor(String color, CallbackContext callbackContext) {
|
|
233
|
+
ymChat.config.theme.secondaryColor = color;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public void setThemeBotIcon(String iconUrl, CallbackContext callbackContext) {
|
|
237
|
+
ymChat.config.theme.botIcon = iconUrl;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public void setThemeBotClickIcon(String iconUrl, CallbackContext callbackContext) {
|
|
241
|
+
ymChat.config.theme.botClickIcon = iconUrl;
|
|
242
|
+
}
|
|
243
|
+
|
|
219
244
|
public void revalidateToken(String token, boolean refreshSession, CallbackContext callbackContext) {
|
|
220
245
|
try {
|
|
221
246
|
ymChat.revalidateToken(token, refreshSession);
|
|
@@ -223,4 +248,13 @@ public class YmChatService {
|
|
|
223
248
|
e.printStackTrace();
|
|
224
249
|
}
|
|
225
250
|
}
|
|
251
|
+
|
|
252
|
+
public void sendEventToBot(String code, JSONObject data, CallbackContext callbackContext) {
|
|
253
|
+
try {
|
|
254
|
+
YMEventModel model = new YMEventModel(code, Utils.jsonToMap(data));
|
|
255
|
+
ymChat.sendEventToBot(model);
|
|
256
|
+
} catch (Exception e) {
|
|
257
|
+
e.printStackTrace();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
226
260
|
}
|
package/src/ios/ymchat.m
CHANGED
|
@@ -235,6 +235,48 @@
|
|
|
235
235
|
YMChat.shared.config.useSecureYmAuth = shouldUseSecureYmAuth;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
- (void)setThemeBotName:(CDVInvokedUrlCommand*)command
|
|
239
|
+
{
|
|
240
|
+
NSString* name = [command.arguments objectAtIndex:0];
|
|
241
|
+
assert(YMChat.shared.config != nil);
|
|
242
|
+
YMChat.shared.config.theme.botName = name;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
- (void)setThemeBotDescription:(CDVInvokedUrlCommand*)command
|
|
246
|
+
{
|
|
247
|
+
NSString* description = [command.arguments objectAtIndex:0];
|
|
248
|
+
assert(YMChat.shared.config != nil);
|
|
249
|
+
YMChat.shared.config.theme.botDescription = description;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
- (void)setThemePrimaryColor:(CDVInvokedUrlCommand*)command
|
|
253
|
+
{
|
|
254
|
+
NSString* color = [command.arguments objectAtIndex:0];
|
|
255
|
+
assert(YMChat.shared.config != nil);
|
|
256
|
+
YMChat.shared.config.theme.primaryColor = [self getColorFromHexString:color];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
- (void)setThemeSecondaryColor:(CDVInvokedUrlCommand*)command
|
|
260
|
+
{
|
|
261
|
+
NSString* color = [command.arguments objectAtIndex:0];
|
|
262
|
+
assert(YMChat.shared.config != nil);
|
|
263
|
+
YMChat.shared.config.theme.secondaryColor = [self getColorFromHexString:color];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
- (void)setThemeBotIcon:(CDVInvokedUrlCommand*)command
|
|
267
|
+
{
|
|
268
|
+
NSString* iconUrl = [command.arguments objectAtIndex:0];
|
|
269
|
+
assert(YMChat.shared.config != nil);
|
|
270
|
+
YMChat.shared.config.theme.botIcon = iconUrl;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
- (void)setThemeBotClickIcon:(CDVInvokedUrlCommand*)command
|
|
274
|
+
{
|
|
275
|
+
NSString* iconUrl = [command.arguments objectAtIndex:0];
|
|
276
|
+
assert(YMChat.shared.config != nil);
|
|
277
|
+
YMChat.shared.config.theme.botClickIcon = iconUrl;
|
|
278
|
+
}
|
|
279
|
+
|
|
238
280
|
- (void)revalidateToken:(CDVInvokedUrlCommand*)command
|
|
239
281
|
{
|
|
240
282
|
NSString* token = [command.arguments objectAtIndex:0];
|
|
@@ -242,6 +284,14 @@
|
|
|
242
284
|
[[YMChat shared] revalidateTokenWithToken:token refreshSession:refreshSession error:nil];
|
|
243
285
|
}
|
|
244
286
|
|
|
287
|
+
- (void)sendEventToBot:(CDVInvokedUrlCommand*)command
|
|
288
|
+
{
|
|
289
|
+
NSString* code = [command.arguments objectAtIndex:0];
|
|
290
|
+
NSDictionary* data = [command.arguments objectAtIndex:1];
|
|
291
|
+
YMEventModel* event = [[YMEventModel alloc] initWithCode:code data:data];
|
|
292
|
+
[[YMChat shared] sendEventToBotWithEvent:event error:nil];
|
|
293
|
+
}
|
|
294
|
+
|
|
245
295
|
- (UIColor *)getColorFromHexString:(NSString *)hexString {
|
|
246
296
|
unsigned rgbValue = 0;
|
|
247
297
|
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
package/www/ymchat.js
CHANGED
|
@@ -74,8 +74,29 @@ const YmChatAPI = {
|
|
|
74
74
|
useSecureYmAuth: (shouldUseSecureYmAuth) => {
|
|
75
75
|
exec(null, null, "ymchat", "useSecureYmAuth", [shouldUseSecureYmAuth]);
|
|
76
76
|
},
|
|
77
|
+
setThemeBotName: (name) => {
|
|
78
|
+
exec(null, null, "ymchat", "setThemeBotName", [name]);
|
|
79
|
+
},
|
|
80
|
+
setThemeBotDescription: (description) => {
|
|
81
|
+
exec(null, null, "ymchat", "setThemeBotDescription", [description]);
|
|
82
|
+
},
|
|
83
|
+
setThemePrimaryColor: (color) => {
|
|
84
|
+
exec(null, null, "ymchat", "setThemePrimaryColor", [color]);
|
|
85
|
+
},
|
|
86
|
+
setThemeSecondaryColor: (color) => {
|
|
87
|
+
exec(null, null, "ymchat", "setThemeSecondaryColor", [color]);
|
|
88
|
+
},
|
|
89
|
+
setThemeBotIcon: (iconUrl) => {
|
|
90
|
+
exec(null, null, "ymchat", "setThemeBotIcon", [iconUrl]);
|
|
91
|
+
},
|
|
92
|
+
setThemeBotClickIcon: (iconUrl) => {
|
|
93
|
+
exec(null, null, "ymchat", "setThemeBotClickIcon", [iconUrl]);
|
|
94
|
+
},
|
|
77
95
|
revalidateToken: (token, refreshSession) => {
|
|
78
96
|
exec(null, null, "ymchat", "revalidateToken", [token, refreshSession]);
|
|
97
|
+
},
|
|
98
|
+
sendEventToBot: (code, data) => {
|
|
99
|
+
exec(null, null, "ymchat", "sendEventToBot", [code, data]);
|
|
79
100
|
}
|
|
80
101
|
};
|
|
81
102
|
|