cordova-plugin-ymchat 2.7.1 → 2.9.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
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.9.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.14.1" 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.9.+'
|
|
28
28
|
}
|
|
@@ -89,6 +89,15 @@ 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;
|
|
98
|
+
case "sendEventToBot":
|
|
99
|
+
sendEventToBot(args,callbackContext);
|
|
100
|
+
return true;
|
|
92
101
|
}
|
|
93
102
|
return false;
|
|
94
103
|
}
|
|
@@ -284,4 +293,33 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
284
293
|
Utils.genericErrorHelper(e, callbackContext);
|
|
285
294
|
}
|
|
286
295
|
}
|
|
296
|
+
|
|
297
|
+
private void useSecureYmAuth(JSONArray args, CallbackContext callbackContext) {
|
|
298
|
+
try {
|
|
299
|
+
boolean shouldUseSecureYmAuth = args.getBoolean(0);
|
|
300
|
+
ymChatService.useSecureYmAuth(shouldUseSecureYmAuth, callbackContext);
|
|
301
|
+
} catch (Exception e) {
|
|
302
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private void revalidateToken(JSONArray args, CallbackContext callbackContext) {
|
|
307
|
+
try {
|
|
308
|
+
String token = args.getString(0);
|
|
309
|
+
boolean refreshSession = args.getBoolean(1);
|
|
310
|
+
ymChatService.revalidateToken(token, refreshSession, callbackContext);
|
|
311
|
+
} catch (Exception e) {
|
|
312
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
private void sendEventToBot(JSONArray args, CallbackContext callbackContext) {
|
|
317
|
+
try {
|
|
318
|
+
String code = args.getString(0);
|
|
319
|
+
JSONObject data = args.getJSONObject(1);
|
|
320
|
+
ymChatService.sendEventToBot(code, data, callbackContext);
|
|
321
|
+
} catch (Exception e) {
|
|
322
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
287
325
|
}
|
|
@@ -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;
|
|
@@ -23,7 +24,7 @@ public class YmChatService {
|
|
|
23
24
|
final String Tag = "YmChat";
|
|
24
25
|
final String ExceptionString = "Exception";
|
|
25
26
|
final String code = "code";
|
|
26
|
-
final String data = "
|
|
27
|
+
final String data = "data";
|
|
27
28
|
|
|
28
29
|
HashMap<String, Object> payloadData = new HashMap<>();
|
|
29
30
|
|
|
@@ -88,7 +89,15 @@ public class YmChatService {
|
|
|
88
89
|
JSONObject jsonObject = new JSONObject();
|
|
89
90
|
try {
|
|
90
91
|
jsonObject.put(code, botEvent.getCode());
|
|
91
|
-
|
|
92
|
+
JSONObject dataJsonObject = new JSONObject();
|
|
93
|
+
if (botEvent.getData() != null) {
|
|
94
|
+
try {
|
|
95
|
+
dataJsonObject = new JSONObject(botEvent.getData());
|
|
96
|
+
}catch(Exception e) {
|
|
97
|
+
Log.e(Tag, ExceptionString, e);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
jsonObject.put(data, dataJsonObject);
|
|
92
101
|
PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObject);
|
|
93
102
|
result.setKeepCallback(true);
|
|
94
103
|
callback.sendPluginResult(result);
|
|
@@ -203,4 +212,25 @@ public class YmChatService {
|
|
|
203
212
|
public void setMicBackgroundColor(String color, CallbackContext callbackContext) {
|
|
204
213
|
ymChat.config.enableSpeechConfig.fabBackgroundColor = color;
|
|
205
214
|
}
|
|
215
|
+
|
|
216
|
+
public void useSecureYmAuth(boolean shouldUseSecureYmAuth, CallbackContext callbackContext) {
|
|
217
|
+
ymChat.config.useSecureYmAuth = shouldUseSecureYmAuth;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public void revalidateToken(String token, boolean refreshSession, CallbackContext callbackContext) {
|
|
221
|
+
try {
|
|
222
|
+
ymChat.revalidateToken(token, refreshSession);
|
|
223
|
+
} catch (Exception e) {
|
|
224
|
+
e.printStackTrace();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public void sendEventToBot(String code, JSONObject data, CallbackContext callbackContext) {
|
|
229
|
+
try {
|
|
230
|
+
YMEventModel model = new YMEventModel(code, Utils.jsonToMap(data));
|
|
231
|
+
ymChat.sendEventToBot(model);
|
|
232
|
+
} catch (Exception e) {
|
|
233
|
+
e.printStackTrace();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
206
236
|
}
|
package/src/ios/ymchat.m
CHANGED
|
@@ -228,6 +228,28 @@
|
|
|
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
|
+
|
|
245
|
+
- (void)sendEventToBot:(CDVInvokedUrlCommand*)command
|
|
246
|
+
{
|
|
247
|
+
NSString* code = [command.arguments objectAtIndex:0];
|
|
248
|
+
NSDictionary* data = [command.arguments objectAtIndex:1];
|
|
249
|
+
YMEventModel* event = [[YMEventModel alloc] initWithCode:code data:data];
|
|
250
|
+
[[YMChat shared] sendEventToBotWithEvent:event error:nil];
|
|
251
|
+
}
|
|
252
|
+
|
|
231
253
|
- (UIColor *)getColorFromHexString:(NSString *)hexString {
|
|
232
254
|
unsigned rgbValue = 0;
|
|
233
255
|
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
package/www/ymchat.js
CHANGED
|
@@ -71,6 +71,15 @@ 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
|
+
},
|
|
80
|
+
sendEventToBot: (code, data) => {
|
|
81
|
+
exec(null, null, "ymchat", "sendEventToBot", [code, data]);
|
|
82
|
+
}
|
|
74
83
|
};
|
|
75
84
|
|
|
76
85
|
module.exports = YmChatAPI;
|