cordova-plugin-ymchat 1.1.0 → 1.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.
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-ymchat",
3
- "version": "1.1.0",
3
+ "version": "1.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="1.1.0"
2
+ <plugin id="cordova-plugin-ymchat" version="1.3.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>
@@ -24,7 +24,7 @@
24
24
  </config-file>
25
25
  <source-file src="src/android/com/yellow/ai/ymchat/YmChatCordova.java" target-dir="src/com/yellow/ai/ymchat" />
26
26
  <source-file src="src/android/com/yellow/ai/ymchat/YmChatService.java" target-dir="src/com/yellow/ai/ymchat" />
27
- <source-file src="src/android/com/yellow/ai/ymchat/Utils/Utils.java" target-dir="src/com/yellow/ai/ymchat/utils" />
27
+ <source-file src="src/android/com/yellow/ai/ymchat/utils/Utils.java" target-dir="src/com/yellow/ai/ymchat/utils" />
28
28
  <framework custom="true" src="src/android/build.gradle" type="gradleReference" />
29
29
  <framework src="androidx.appcompat:appcompat:1.0.0" />
30
30
  </platform>
@@ -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.4.0" swift-version="5.0"/>
37
+ <pod name="YMChat" spec="~> 1.7" 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:v1.5.0'
27
+ implementation 'com.github.yellowmessenger:YMChatbot-Android:v1.8.+'
28
28
  }
@@ -56,10 +56,40 @@ public class YmChatCordova extends CordovaPlugin {
56
56
  case "unlinkDeviceToken":
57
57
  unlinkDeviceToken(args, callbackContext);
58
58
  return true;
59
+ case "setVersion":
60
+ setVersion(args,callbackContext);
61
+ return true;
62
+ case "setStatusBarColour":
63
+ setStatusBarColour(args,callbackContext);
64
+ return true;
65
+ case "setCloseButtonColour":
66
+ setCloseButtonColour(args,callbackContext);
67
+ return true;
68
+ case "setCustomLoaderURL":
69
+ setCustomLoaderURL(args, callbackContext);
70
+ return true;
59
71
  }
60
72
  return false;
61
73
  }
62
74
 
75
+ private void setCloseButtonColour(JSONArray args, CallbackContext callbackContext) {
76
+ try {
77
+ String colour = args.getString(0);
78
+ ymChatService.setCloseButtonColour(colour, callbackContext);
79
+ } catch (Exception e) {
80
+ Utils.genericErrorHelper(e, callbackContext);
81
+ }
82
+ }
83
+
84
+ private void setStatusBarColour(JSONArray args, CallbackContext callbackContext) {
85
+ try {
86
+ String colour = args.getString(0);
87
+ ymChatService.setStatusBarColour(colour, callbackContext);
88
+ } catch (Exception e) {
89
+ Utils.genericErrorHelper(e, callbackContext);
90
+ }
91
+ }
92
+
63
93
  public void setBotId(JSONArray args, CallbackContext callbackContext) {
64
94
  try {
65
95
  String botId = args.getString(0);
@@ -160,4 +190,23 @@ public class YmChatCordova extends CordovaPlugin {
160
190
  }
161
191
  }
162
192
 
193
+ private void setVersion(JSONArray args, CallbackContext callbackContext) {
194
+ try{
195
+ int version = args.getInt(0);
196
+ ymChatService.setVersion(version,callbackContext);
197
+ }catch(Exception e)
198
+ {
199
+ Utils.genericErrorHelper(e, callbackContext);
200
+ }
201
+ }
202
+
203
+ public void setCustomLoaderURL(JSONArray args, CallbackContext callbackContext) {
204
+ try {
205
+ String customUrl = args.getString(0);
206
+ ymChatService.setCustomLoaderUrl(customUrl, callbackContext);
207
+ } catch (Exception e) {
208
+ Utils.genericErrorHelper(e, callbackContext);
209
+ }
210
+ }
211
+
163
212
  }
@@ -11,6 +11,7 @@ import com.yellowmessenger.ymchat.models.YellowCallback;
11
11
 
12
12
  import org.apache.cordova.CallbackContext;
13
13
  import org.apache.cordova.PluginResult;
14
+ import org.json.JSONArray;
14
15
  import org.json.JSONObject;
15
16
 
16
17
  import java.util.HashMap;
@@ -123,4 +124,20 @@ public class YmChatService {
123
124
  Utils.genericErrorHelper(e, callbackContext);
124
125
  }
125
126
  }
127
+
128
+ public void setVersion(int version, CallbackContext callbackContext) {
129
+ ymChat.config.version = version;
130
+ }
131
+
132
+ public void setCustomLoaderUrl(String url, CallbackContext callbackContext) {
133
+ ymChat.config.customLoaderUrl = url;
134
+ }
135
+
136
+ public void setCloseButtonColour(String colour, CallbackContext callbackContext) {
137
+ ymChat.config.closeButtonColorHex = colour;
138
+ }
139
+
140
+ public void setStatusBarColour(String colour, CallbackContext callbackContext) {
141
+ ymChat.config.statusBarColorFromHex = colour;
142
+ }
126
143
  }
package/src/ios/ymchat.m CHANGED
@@ -108,6 +108,13 @@
108
108
  [self.commandDelegate sendPluginResult:pluginResult callbackId:onBotClosed.callbackId];
109
109
  }
110
110
 
111
+ - (void)setVersion:(CDVInvokedUrlCommand*)command
112
+ {
113
+ assert(YMChat.shared.config != nil);
114
+ NSNumber* version = [command.arguments objectAtIndex:0];
115
+ YMChat.shared.config.version = version.integerValue;
116
+ }
117
+
111
118
  - (void) unlinkDeviceToken:(CDVInvokedUrlCommand*)command {
112
119
  NSString* botId = [command.arguments objectAtIndex:0];
113
120
  NSString* apiKey = [command.arguments objectAtIndex:1];
@@ -123,4 +130,37 @@
123
130
  }];
124
131
  }
125
132
 
133
+ - (void)setCustomLoaderURL:(CDVInvokedUrlCommand*)command
134
+ {
135
+ NSString* url = [command.arguments objectAtIndex:0];
136
+ assert(YMChat.shared.config != nil);
137
+ YMChat.shared.config.customLoaderUrl = url;
138
+ }
139
+
140
+ - (void)setStatusBarColour:(CDVInvokedUrlCommand*)command
141
+ {
142
+ NSString* colour = [command.arguments objectAtIndex:0];
143
+ assert(YMChat.shared.config != nil);
144
+ YMChat.shared.config.statusBarColor = [self getColorFromHexString:colour];
145
+ }
146
+
147
+ - (void)setCloseButtonColour:(CDVInvokedUrlCommand*)command
148
+ {
149
+ NSString* colour = [command.arguments objectAtIndex:0];
150
+ assert(YMChat.shared.config != nil);
151
+ YMChat.shared.config.closeButtonColor = [self getColorFromHexString:colour];
152
+ }
153
+
154
+ - (UIColor *)getColorFromHexString:(NSString *)hexString {
155
+ unsigned rgbValue = 0;
156
+ NSScanner *scanner = [NSScanner scannerWithString:hexString];
157
+ if ([(NSString*) hexString characterAtIndex:0] == '#') {
158
+ [scanner setScanLocation:1]; // bypass '#' character
159
+ } else {
160
+ [scanner setScanLocation:0];
161
+ }
162
+ [scanner scanHexInt:&rgbValue];
163
+ return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
164
+ }
165
+
126
166
  @end
package/www/ymchat.js CHANGED
@@ -37,6 +37,18 @@ const YmChatAPI = {
37
37
  },
38
38
  unlinkDeviceToken: (botId, apiKey, deviceToken, success, failure) => {
39
39
  exec(success, failure, "ymchat", "unlinkDeviceToken", [botId, apiKey, deviceToken])
40
+ },
41
+ setVersion: (version) => {
42
+ exec(null, null, "ymchat", "setVersion", [version])
43
+ },
44
+ setCustomLoaderURL: (url) => {
45
+ exec(null, null, "ymchat", "setCustomLoaderURL", [url]);
46
+ },
47
+ setStatusBarColour: (colour) => {
48
+ exec(null, null, "ymchat", "setStatusBarColour", [colour]);
49
+ },
50
+ setCloseButtonColour: (colour) => {
51
+ exec(null, null, "ymchat", "setCloseButtonColour", [colour]);
40
52
  }
41
53
  };
42
54