cordova-plugin-ymchat 1.0.3 → 1.3.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/{README.md → Readme.md} +0 -0
- package/package.json +1 -1
- package/plugin.xml +4 -4
- package/src/android/.idea/gradle.xml +17 -0
- package/src/android/.idea/misc.xml +9 -0
- package/src/android/.idea/modules/android.iml +18 -0
- package/src/android/.idea/modules.xml +8 -0
- package/src/android/.idea/vcs.xml +6 -0
- package/src/android/build.gradle +2 -3
- package/src/android/com/yellow/ai/ymchat/YmChatCordova.java +41 -14
- package/src/android/com/yellow/ai/ymchat/YmChatService.java +32 -5
- package/src/android/local.properties +8 -0
- package/src/ios/ymchat.m +29 -7
- package/www/ymchat.js +9 -3
package/{README.md → Readme.md}
RENAMED
|
File without changes
|
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="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/
|
|
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.
|
|
37
|
+
<pod name="YMChat" spec="~> 1.5" swift-version="5.0"/>
|
|
38
38
|
</pods>
|
|
39
39
|
</podspec>
|
|
40
40
|
<config-file parent="/*" target="config.xml">
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
<param name="ios-package" value="ymchat"/>
|
|
43
43
|
<param name="onload" value="true" />
|
|
44
44
|
</feature>
|
|
45
|
-
<preference name="deployment-target" value="
|
|
45
|
+
<preference name="deployment-target" value="13.0" />
|
|
46
46
|
<preference name="target-device" value="universal" />
|
|
47
47
|
</config-file>
|
|
48
48
|
<preference name="MICROPHONE_USAGE_DESCRIPTION" default="Your microphone will be used to record your speech when you use the Voice feature."/>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
4
|
+
<component name="GradleSettings">
|
|
5
|
+
<option name="linkedExternalProjectsSettings">
|
|
6
|
+
<GradleProjectSettings>
|
|
7
|
+
<option name="testRunner" value="PLATFORM" />
|
|
8
|
+
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
9
|
+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
10
|
+
<option name="gradleHome" value="/usr/local/Cellar/gradle/7.1.1/libexec" />
|
|
11
|
+
<option name="gradleJvm" value="1.8 (2)" />
|
|
12
|
+
<option name="resolveModulePerSourceSet" value="false" />
|
|
13
|
+
<option name="useQualifiedModuleNames" value="true" />
|
|
14
|
+
</GradleProjectSettings>
|
|
15
|
+
</option>
|
|
16
|
+
</component>
|
|
17
|
+
</project>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
|
4
|
+
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ProjectType">
|
|
7
|
+
<option name="id" value="Android" />
|
|
8
|
+
</component>
|
|
9
|
+
</project>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module external.linked.project.id=":" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="FacetManager">
|
|
4
|
+
<facet type="android-gradle" name="Android-Gradle">
|
|
5
|
+
<configuration>
|
|
6
|
+
<option name="GRADLE_PROJECT_PATH" value=":" />
|
|
7
|
+
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" />
|
|
8
|
+
<option name="LAST_KNOWN_AGP_VERSION" />
|
|
9
|
+
</configuration>
|
|
10
|
+
</facet>
|
|
11
|
+
</component>
|
|
12
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
13
|
+
<exclude-output />
|
|
14
|
+
<content url="file://$MODULE_DIR$/../.." />
|
|
15
|
+
<orderEntry type="inheritedJdk" />
|
|
16
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
17
|
+
</component>
|
|
18
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/modules/android.iml" filepath="$PROJECT_DIR$/.idea/modules/android.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/src/android/build.gradle
CHANGED
|
@@ -24,6 +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.
|
|
28
|
-
}
|
|
29
|
-
|
|
27
|
+
implementation 'com.github.yellowmessenger:YMChatbot-Android:v1.7.+'
|
|
28
|
+
}
|
|
@@ -8,7 +8,6 @@ import com.yellow.ai.ymchat.utils.Utils;
|
|
|
8
8
|
import org.apache.cordova.CallbackContext;
|
|
9
9
|
import org.apache.cordova.CordovaPlugin;
|
|
10
10
|
import org.json.JSONArray;
|
|
11
|
-
import org.json.JSONException;
|
|
12
11
|
import org.json.JSONObject;
|
|
13
12
|
|
|
14
13
|
public class YmChatCordova extends CordovaPlugin {
|
|
@@ -30,9 +29,6 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
30
29
|
case "setEnableSpeech":
|
|
31
30
|
setEnableSpeech(args, callbackContext);
|
|
32
31
|
return true;
|
|
33
|
-
case "setEnableHistory":
|
|
34
|
-
setEnableHistory(args, callbackContext);
|
|
35
|
-
return true;
|
|
36
32
|
case "setAuthenticationToken":
|
|
37
33
|
setAuthenticationToken(args, callbackContext);
|
|
38
34
|
return true;
|
|
@@ -52,11 +48,20 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
52
48
|
onBotClose(callbackContext);
|
|
53
49
|
return true;
|
|
54
50
|
case "startChatbot":
|
|
55
|
-
|
|
51
|
+
startChatbot(callbackContext);
|
|
56
52
|
return true;
|
|
57
53
|
case "closeBot":
|
|
58
54
|
closeBot();
|
|
59
55
|
return true;
|
|
56
|
+
case "unlinkDeviceToken":
|
|
57
|
+
unlinkDeviceToken(args, callbackContext);
|
|
58
|
+
return true;
|
|
59
|
+
case "setVersion":
|
|
60
|
+
setVersion(args,callbackContext);
|
|
61
|
+
return true;
|
|
62
|
+
case "setCustomLoaderURL":
|
|
63
|
+
setCustomLoaderURL(args, callbackContext);
|
|
64
|
+
return true;
|
|
60
65
|
}
|
|
61
66
|
return false;
|
|
62
67
|
}
|
|
@@ -106,15 +111,6 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
public void setEnableHistory(JSONArray args, CallbackContext callbackContext) {
|
|
110
|
-
try {
|
|
111
|
-
boolean enableHistory = args.getBoolean(0);
|
|
112
|
-
ymChatService.setEnableHistory(enableHistory, callbackContext);
|
|
113
|
-
} catch (Exception e) {
|
|
114
|
-
Utils.genericErrorHelper(e, callbackContext);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
114
|
public void setAuthenticationToken(JSONArray args, CallbackContext callbackContext) {
|
|
119
115
|
try {
|
|
120
116
|
String authToken = args.getString(0);
|
|
@@ -158,4 +154,35 @@ public class YmChatCordova extends CordovaPlugin {
|
|
|
158
154
|
public void onBotClose(CallbackContext onBotCloseEvent) {
|
|
159
155
|
ymChatService.onBotClose(onBotCloseEvent);
|
|
160
156
|
}
|
|
157
|
+
|
|
158
|
+
private void unlinkDeviceToken(JSONArray args, CallbackContext callbackContext) {
|
|
159
|
+
try {
|
|
160
|
+
String botId = args.getString(0);
|
|
161
|
+
String apiKey = args.getString(1);
|
|
162
|
+
String deviceToken = args.getString(2);
|
|
163
|
+
ymChatService.unlinkDeviceToken(botId, apiKey, deviceToken, callbackContext);
|
|
164
|
+
} catch (Exception e) {
|
|
165
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private void setVersion(JSONArray args, CallbackContext callbackContext) {
|
|
170
|
+
try{
|
|
171
|
+
int version = args.getInt(0);
|
|
172
|
+
ymChatService.setVersion(version,callbackContext);
|
|
173
|
+
}catch(Exception e)
|
|
174
|
+
{
|
|
175
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public void setCustomLoaderURL(JSONArray args, CallbackContext callbackContext) {
|
|
180
|
+
try {
|
|
181
|
+
String customUrl = args.getString(0);
|
|
182
|
+
ymChatService.setCustomLoaderUrl(customUrl, callbackContext);
|
|
183
|
+
} catch (Exception e) {
|
|
184
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
161
188
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
package com.yellow.ai.ymchat;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
+
import android.net.Uri;
|
|
4
5
|
import android.util.Log;
|
|
5
6
|
|
|
6
7
|
import com.yellow.ai.ymchat.utils.Utils;
|
|
7
8
|
import com.yellowmessenger.ymchat.YMChat;
|
|
8
9
|
import com.yellowmessenger.ymchat.YMConfig;
|
|
10
|
+
import com.yellowmessenger.ymchat.models.YellowCallback;
|
|
9
11
|
|
|
10
12
|
import org.apache.cordova.CallbackContext;
|
|
11
13
|
import org.apache.cordova.PluginResult;
|
|
14
|
+
import org.json.JSONArray;
|
|
12
15
|
import org.json.JSONObject;
|
|
13
16
|
|
|
14
17
|
import java.util.HashMap;
|
|
@@ -18,7 +21,7 @@ public class YmChatService {
|
|
|
18
21
|
final String Tag = "YmChat";
|
|
19
22
|
final String ExceptionString = "Exception";
|
|
20
23
|
final String code = "code";
|
|
21
|
-
final String data = "
|
|
24
|
+
final String data = "date";
|
|
22
25
|
|
|
23
26
|
HashMap<String, Object> payloadData = new HashMap<>();
|
|
24
27
|
|
|
@@ -52,10 +55,6 @@ public class YmChatService {
|
|
|
52
55
|
ymChat.config.enableSpeech = speech;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
public void setEnableHistory(boolean history, CallbackContext callbackContext) {
|
|
56
|
-
ymChat.config.enableHistory = history;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
58
|
public void setAuthenticationToken(String token, CallbackContext callbackContext) {
|
|
60
59
|
ymChat.config.ymAuthenticationToken = token;
|
|
61
60
|
}
|
|
@@ -105,4 +104,32 @@ public class YmChatService {
|
|
|
105
104
|
}
|
|
106
105
|
});
|
|
107
106
|
}
|
|
107
|
+
|
|
108
|
+
public void unlinkDeviceToken(String botId, String apiKey, String deviceToken,CallbackContext callbackContext) {
|
|
109
|
+
try{
|
|
110
|
+
ymChat.unlinkDeviceToken(botId, apiKey, deviceToken, new YellowCallback() {
|
|
111
|
+
@Override
|
|
112
|
+
public void success() {
|
|
113
|
+
callbackContext.success();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@Override
|
|
117
|
+
public void failure(String message) {
|
|
118
|
+
Utils.genericErrorHelper(new Exception(),callbackContext);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (Exception e)
|
|
123
|
+
{
|
|
124
|
+
Utils.genericErrorHelper(e, callbackContext);
|
|
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
|
+
}
|
|
108
135
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
+
# as it contains information specific to your local configuration.
|
|
3
|
+
#
|
|
4
|
+
# Location of the SDK. This is only used by Gradle.
|
|
5
|
+
# For customization when using a Version Control System, please read the
|
|
6
|
+
# header note.
|
|
7
|
+
#Fri Sep 24 13:53:23 IST 2021
|
|
8
|
+
sdk.dir=/Users/purush/Library/Android/sdk
|
package/src/ios/ymchat.m
CHANGED
|
@@ -35,13 +35,6 @@
|
|
|
35
35
|
YMChat.shared.config.enableSpeech = enableSpeech;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
- (void)setEnableHistory:(CDVInvokedUrlCommand*)command
|
|
39
|
-
{
|
|
40
|
-
BOOL history = [command.arguments objectAtIndex:0];
|
|
41
|
-
assert(YMChat.shared.config != nil);
|
|
42
|
-
YMChat.shared.config.enableHistory = history;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
38
|
- (void)setAuthenticationToken:(CDVInvokedUrlCommand*)command
|
|
46
39
|
{
|
|
47
40
|
NSString* authToken = [command.arguments objectAtIndex:0];
|
|
@@ -115,4 +108,33 @@
|
|
|
115
108
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:onBotClosed.callbackId];
|
|
116
109
|
}
|
|
117
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
|
+
|
|
118
|
+
- (void) unlinkDeviceToken:(CDVInvokedUrlCommand*)command {
|
|
119
|
+
NSString* botId = [command.arguments objectAtIndex:0];
|
|
120
|
+
NSString* apiKey = [command.arguments objectAtIndex:1];
|
|
121
|
+
NSString* deviceToken = [command.arguments objectAtIndex:2];
|
|
122
|
+
[[YMChat shared] unlinkDeviceTokenWithBotId:botId apiKey:apiKey deviceToken:deviceToken success:^{
|
|
123
|
+
CDVPluginResult* pluginResult = nil;
|
|
124
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
125
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
126
|
+
} failure:^(NSString * _Nonnull failureMessage) {
|
|
127
|
+
CDVPluginResult* pluginResult = nil;
|
|
128
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:failureMessage];
|
|
129
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
130
|
+
}];
|
|
131
|
+
}
|
|
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
|
+
|
|
118
140
|
@end
|
package/www/ymchat.js
CHANGED
|
@@ -11,9 +11,6 @@ const YmChatAPI = {
|
|
|
11
11
|
setEnableSpeech: (speech) => {
|
|
12
12
|
exec(null, null, "ymchat", "setEnableSpeech", [speech]);
|
|
13
13
|
},
|
|
14
|
-
setEnableHistory: (history) => {
|
|
15
|
-
exec(null, null, "ymchat", "setEnableHistory", [history]);
|
|
16
|
-
},
|
|
17
14
|
setAuthenticationToken: (token) => {
|
|
18
15
|
exec(null, null, "ymchat", "setAuthenticationToken", [token]);
|
|
19
16
|
},
|
|
@@ -38,6 +35,15 @@ const YmChatAPI = {
|
|
|
38
35
|
closeBot: () => {
|
|
39
36
|
exec(null, null, "ymchat", "closeBot", []);
|
|
40
37
|
},
|
|
38
|
+
unlinkDeviceToken: (botId, apiKey, deviceToken, success, failure) => {
|
|
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
|
+
}
|
|
41
47
|
};
|
|
42
48
|
|
|
43
49
|
module.exports = YmChatAPI;
|