metamap-capacitor-plugin 4.7.19 â 4.8.1
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.
|
@@ -8,9 +8,8 @@ Pod::Spec.new do |s|
|
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.license = package['license']
|
|
10
10
|
s.homepage = package['repository']['url']
|
|
11
|
-
s.author = { 'Avo Sukiasyan' => 'avetik.sukiasyan.com' }
|
|
11
|
+
s.author = { 'Avo Sukiasyan' => 'avetik.sukiasyan@metamap.com' }
|
|
12
12
|
s.source = { :path => '.' }
|
|
13
|
-
|
|
14
13
|
s.ios.deployment_target = '13.0'
|
|
15
14
|
s.swift_version = '5.1'
|
|
16
15
|
s.static_framework = true
|
package/android/build.gradle
CHANGED
|
@@ -54,7 +54,7 @@ dependencies {
|
|
|
54
54
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
55
55
|
implementation project(':capacitor-android')
|
|
56
56
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
57
|
-
implementation ('com.metamap:android-sdk:3.42.
|
|
57
|
+
implementation ('com.metamap:android-sdk:3.42.8') {
|
|
58
58
|
exclude group: "com.airbnb.android", module: "lottie-compose"
|
|
59
59
|
exclude group: "org.jetbrains.compose.runtime", module: "runtime-android"
|
|
60
60
|
exclude group: "org.jetbrains.compose.runtime", module: "runtime-desktop"
|
|
@@ -1,108 +1,8 @@
|
|
|
1
|
-
//package com.getmati.plugins.capacitor;
|
|
2
|
-
//
|
|
3
|
-
//import android.app.Activity;
|
|
4
|
-
//import android.content.Intent;
|
|
5
|
-
//import android.util.Log;
|
|
6
|
-
//import androidx.activity.result.ActivityResult;
|
|
7
|
-
//import com.getcapacitor.JSObject;
|
|
8
|
-
//import com.getcapacitor.Plugin;
|
|
9
|
-
//import com.getcapacitor.PluginCall;
|
|
10
|
-
//import com.getcapacitor.PluginMethod;
|
|
11
|
-
//import com.getcapacitor.annotation.ActivityCallback;
|
|
12
|
-
//import com.getcapacitor.annotation.CapacitorPlugin;
|
|
13
|
-
//import com.metamap.metamap_sdk.MetamapSdk;
|
|
14
|
-
//import com.metamap.metamap_sdk.Metadata;
|
|
15
|
-
//import org.json.JSONObject;
|
|
16
|
-
//import org.json.JSONException;
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//import java.util.Iterator;
|
|
20
|
-
//
|
|
21
|
-
//import android.graphics.Color;
|
|
22
|
-
//
|
|
23
|
-
//@CapacitorPlugin(name = "MetaMapCapacitor")
|
|
24
|
-
//public class MetaMapCapacitorPlugin extends Plugin {
|
|
25
|
-
//
|
|
26
|
-
// @SuppressWarnings("unused")
|
|
27
|
-
// @PluginMethod
|
|
28
|
-
// public void showMetaMapFlow(PluginCall call) {
|
|
29
|
-
// Log.e("MetaMapCapacitorPlugin", "showMetaMapFlow");
|
|
30
|
-
// bridge.getActivity().runOnUiThread(new Runnable() {
|
|
31
|
-
// @Override
|
|
32
|
-
// public void run() {
|
|
33
|
-
//
|
|
34
|
-
// final String clientId = call.getString("clientId");
|
|
35
|
-
// final String flowId = call.getString("flowId");
|
|
36
|
-
// final JSONObject metadata = call.getObject("metadata", new JSObject());
|
|
37
|
-
// try {
|
|
38
|
-
// if (clientId == null) {
|
|
39
|
-
// Log.e("MetaMapCapacitorPlugin", "\"Client Id should be not null\"");
|
|
40
|
-
// } else {
|
|
41
|
-
//
|
|
42
|
-
// Iterator<String> keys = metadata.keys();
|
|
43
|
-
//
|
|
44
|
-
// Metadata.Builder metadataBuilder = new Metadata.Builder();
|
|
45
|
-
//
|
|
46
|
-
// while (keys.hasNext()) {
|
|
47
|
-
// String key = keys.next();
|
|
48
|
-
// try {
|
|
49
|
-
// if (key.toLowerCase().contains("color")) {
|
|
50
|
-
// String hexColor = (String) metadata.get(key);
|
|
51
|
-
// int color = Color.parseColor(hexColor);
|
|
52
|
-
// if (hexColor.length() == 9) {
|
|
53
|
-
// color = Color.argb(Color.blue(color), Color.alpha(color), Color.red(color), Color.green(color));
|
|
54
|
-
// }
|
|
55
|
-
// metadataBuilder.with(key, color);
|
|
56
|
-
// } else {
|
|
57
|
-
// metadataBuilder.with(key, metadata.get(key));
|
|
58
|
-
// }
|
|
59
|
-
// } catch (Exception e) {
|
|
60
|
-
// throw new RuntimeException(e);
|
|
61
|
-
// }
|
|
62
|
-
// }
|
|
63
|
-
// metadataBuilder.with("sdkType", "capacitor");
|
|
64
|
-
// Metadata data = metadataBuilder.build();
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
// Intent flowIntent = MetamapSdk.INSTANCE.createFlowIntent(bridge.getActivity(), clientId, flowId, data, null, null);
|
|
70
|
-
// startActivityForResult(call, flowIntent, "callback");
|
|
71
|
-
// }
|
|
72
|
-
// } catch(Exception excepion) {
|
|
73
|
-
// call.reject("Verification failed");
|
|
74
|
-
// }
|
|
75
|
-
// }
|
|
76
|
-
// });
|
|
77
|
-
// }
|
|
78
|
-
//
|
|
79
|
-
// @Override
|
|
80
|
-
// protected void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
|
|
81
|
-
// super.handleOnActivityResult(requestCode, resultCode, data);
|
|
82
|
-
// Log.e("MetaMapCapacitorPlugin", "WILL NOT BE CALLED");
|
|
83
|
-
// }
|
|
84
|
-
//
|
|
85
|
-
// @SuppressWarnings("unused")
|
|
86
|
-
// @ActivityCallback
|
|
87
|
-
// public void callback(PluginCall call, ActivityResult activityResult) {
|
|
88
|
-
// if(activityResult.getResultCode() == Activity.RESULT_OK && activityResult.getData() != null) {
|
|
89
|
-
// JSObject result = new JSObject();
|
|
90
|
-
// String identityId = activityResult.getData().getStringExtra("ARG_IDENTITY_ID");
|
|
91
|
-
// String verificationID = activityResult.getData().getStringExtra("ARG_VERIFICATION_ID");
|
|
92
|
-
// result.put("identityId", identityId);
|
|
93
|
-
// result.put("verificationID", verificationID);
|
|
94
|
-
// call.resolve(result);
|
|
95
|
-
// Log.e("MetaMapCapacitorPlugin", "Activity.RESULT_OK");
|
|
96
|
-
// } else {
|
|
97
|
-
// call.reject("verificationCancelled");
|
|
98
|
-
// Log.e("MetaMapCapacitorPlugin", "Activity.RESULT_CANCELLED");
|
|
99
|
-
// }
|
|
100
|
-
// }
|
|
101
|
-
//}
|
|
102
1
|
package com.getmati.plugins.capacitor;
|
|
103
2
|
|
|
104
3
|
import android.app.Activity;
|
|
105
4
|
import android.content.Intent;
|
|
5
|
+
import android.graphics.Color;
|
|
106
6
|
import android.util.Log;
|
|
107
7
|
import androidx.activity.result.ActivityResult;
|
|
108
8
|
|
|
@@ -119,20 +19,22 @@ import org.json.JSONObject;
|
|
|
119
19
|
|
|
120
20
|
import java.util.Iterator;
|
|
121
21
|
|
|
122
|
-
import android.graphics.Color;
|
|
123
|
-
|
|
124
22
|
@CapacitorPlugin(name = "MetaMapCapacitor")
|
|
125
23
|
public class MetaMapCapacitorPlugin extends Plugin {
|
|
126
24
|
|
|
25
|
+
private static final String TAG = "đ˛ MetaMapCapacitor";
|
|
26
|
+
|
|
127
27
|
@PluginMethod
|
|
128
28
|
public void showMetaMapFlow(PluginCall call) {
|
|
129
|
-
Log.d(
|
|
29
|
+
Log.d(TAG, "đ showMetaMapFlow invoked");
|
|
30
|
+
|
|
130
31
|
bridge.getActivity().runOnUiThread(() -> {
|
|
131
32
|
String clientId = call.getString("clientId");
|
|
132
33
|
String flowId = call.getString("flowId");
|
|
133
34
|
JSONObject metadata = call.getObject("metadata", new JSObject());
|
|
134
35
|
|
|
135
36
|
if (clientId == null || clientId.isEmpty()) {
|
|
37
|
+
Log.e(TAG, "â Missing clientId");
|
|
136
38
|
call.reject("Client Id should not be null or empty");
|
|
137
39
|
return;
|
|
138
40
|
}
|
|
@@ -140,28 +42,31 @@ public class MetaMapCapacitorPlugin extends Plugin {
|
|
|
140
42
|
try {
|
|
141
43
|
Metadata.Builder metadataBuilder = new Metadata.Builder();
|
|
142
44
|
|
|
45
|
+
// Process metadata
|
|
143
46
|
Iterator<String> keys = metadata.keys();
|
|
144
47
|
while (keys.hasNext()) {
|
|
145
48
|
String key = keys.next();
|
|
146
49
|
try {
|
|
147
|
-
|
|
148
|
-
|
|
50
|
+
Object value = metadata.get(key);
|
|
51
|
+
if (key.toLowerCase().contains("color") && value instanceof String) {
|
|
52
|
+
String hexColor = (String) value;
|
|
149
53
|
int color = Color.parseColor(hexColor);
|
|
150
54
|
if (hexColor.length() == 9) {
|
|
151
55
|
color = Color.argb(Color.blue(color), Color.alpha(color), Color.red(color), Color.green(color));
|
|
152
56
|
}
|
|
153
57
|
metadataBuilder.with(key, color);
|
|
154
58
|
} else {
|
|
155
|
-
metadataBuilder.with(key,
|
|
59
|
+
metadataBuilder.with(key, value);
|
|
156
60
|
}
|
|
157
61
|
} catch (Exception e) {
|
|
158
|
-
Log.e(
|
|
62
|
+
Log.e(TAG, "â ī¸ Error parsing metadata key: " + key, e);
|
|
159
63
|
}
|
|
160
64
|
}
|
|
161
65
|
|
|
162
66
|
metadataBuilder.with("sdkType", "capacitor");
|
|
163
67
|
Metadata builtMetadata = metadataBuilder.build();
|
|
164
68
|
|
|
69
|
+
// Create flow intent with verificationStarted callback
|
|
165
70
|
Intent flowIntent = MetamapSdk.INSTANCE.createFlowIntent(
|
|
166
71
|
bridge.getActivity(),
|
|
167
72
|
clientId,
|
|
@@ -170,7 +75,7 @@ public class MetaMapCapacitorPlugin extends Plugin {
|
|
|
170
75
|
null,
|
|
171
76
|
null,
|
|
172
77
|
(identityId, verificationId) -> {
|
|
173
|
-
Log.d(
|
|
78
|
+
Log.d(TAG, "đĄ verificationStarted: identityId=" + identityId + ", verificationId=" + verificationId);
|
|
174
79
|
JSObject startedResult = new JSObject();
|
|
175
80
|
startedResult.put("identityId", identityId != null ? identityId : "");
|
|
176
81
|
startedResult.put("verificationId", verificationId != null ? verificationId : "");
|
|
@@ -178,10 +83,12 @@ public class MetaMapCapacitorPlugin extends Plugin {
|
|
|
178
83
|
notifyListeners("verificationCreated", startedResult);
|
|
179
84
|
}
|
|
180
85
|
);
|
|
86
|
+
|
|
87
|
+
Log.d(TAG, "đ Starting MetaMap flow...");
|
|
181
88
|
startActivityForResult(call, flowIntent, "callback");
|
|
182
89
|
|
|
183
90
|
} catch (Exception e) {
|
|
184
|
-
Log.e(
|
|
91
|
+
Log.e(TAG, "đĨ Failed to start MetaMap flow", e);
|
|
185
92
|
call.reject("Failed to start MetaMap flow: " + e.getMessage());
|
|
186
93
|
}
|
|
187
94
|
});
|
|
@@ -191,6 +98,7 @@ public class MetaMapCapacitorPlugin extends Plugin {
|
|
|
191
98
|
private void callback(PluginCall call, ActivityResult activityResult) {
|
|
192
99
|
Intent data = activityResult.getData();
|
|
193
100
|
if (data == null) {
|
|
101
|
+
Log.e(TAG, "â MetaMap returned null data");
|
|
194
102
|
call.reject("MetaMap result data is null");
|
|
195
103
|
return;
|
|
196
104
|
}
|
|
@@ -203,11 +111,11 @@ public class MetaMapCapacitorPlugin extends Plugin {
|
|
|
203
111
|
result.put("verificationId", verificationId != null ? verificationId : "");
|
|
204
112
|
|
|
205
113
|
if (activityResult.getResultCode() == Activity.RESULT_OK) {
|
|
206
|
-
Log.d(
|
|
114
|
+
Log.d(TAG, "â
verificationSuccess: identityId=" + identityId + ", verificationId=" + verificationId);
|
|
207
115
|
call.resolve(result);
|
|
208
116
|
} else {
|
|
209
117
|
result.put("status", "cancelled");
|
|
210
|
-
Log.d(
|
|
118
|
+
Log.d(TAG, "â verificationCancelled: identityId=" + identityId + ", verificationId=" + verificationId);
|
|
211
119
|
call.reject(
|
|
212
120
|
"Verification was cancelled by the user",
|
|
213
121
|
"verificationCancelled",
|
package/ios/Plugin/Plugin.swift
CHANGED
|
@@ -5,56 +5,78 @@ import MetaMapSDK
|
|
|
5
5
|
@objc(MetaMapCapacitorPlugin)
|
|
6
6
|
public class MetaMapCapacitorPlugin: CAPPlugin {
|
|
7
7
|
|
|
8
|
-
var output: CAPPluginCall?
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
private var output: CAPPluginCall?
|
|
9
|
+
|
|
10
|
+
@objc func showMetaMapFlow(_ call: CAPPluginCall) {
|
|
11
|
+
DispatchQueue.main.async { [weak self] in
|
|
12
|
+
guard let self = self else { return }
|
|
13
|
+
|
|
14
|
+
let clientId = call.getString("clientId") ?? ""
|
|
15
|
+
let flowId = call.getString("flowId") ?? ""
|
|
16
|
+
var metadata = call.getObject("metadata") as? [String: Any] ?? [:]
|
|
17
|
+
metadata["sdk_type"] = "capacitor"
|
|
18
|
+
|
|
19
|
+
self.output = call
|
|
20
|
+
MetaMapButtonResult.shared.delegate = self
|
|
21
|
+
|
|
22
|
+
print("đ [MetaMapCapacitor] Starting flow with:")
|
|
23
|
+
print(" âĸ clientId: \(clientId)")
|
|
24
|
+
print(" âĸ flowId: \(flowId)")
|
|
25
|
+
print(" âĸ metadata: \(metadata)")
|
|
26
|
+
|
|
27
|
+
MetaMap.shared.showMetaMapFlow(
|
|
28
|
+
clientId: clientId,
|
|
29
|
+
flowId: flowId,
|
|
30
|
+
metadata: metadata
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
extension MetaMapCapacitorPlugin: MetaMapButtonResultDelegate {
|
|
27
37
|
public func verificationSuccess(identityId: String?, verificationID: String?) {
|
|
28
|
-
|
|
38
|
+
let identity = identityId ?? "nil"
|
|
39
|
+
let verification = verificationID ?? "nil"
|
|
40
|
+
print("â
[MetaMapCapacitor] verificationSuccess")
|
|
41
|
+
print(" âĸ identityId: \(identity)")
|
|
42
|
+
print(" âĸ verificationId: \(verification)")
|
|
29
43
|
|
|
30
44
|
output?.resolve([
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
"identityId": identity,
|
|
46
|
+
"verificationId": verification,
|
|
47
|
+
"status": "success"
|
|
48
|
+
])
|
|
35
49
|
}
|
|
36
50
|
|
|
37
51
|
public func verificationCancelled(identityId: String?, verificationID: String?) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
let identity = identityId ?? "nil"
|
|
53
|
+
let verification = verificationID ?? "nil"
|
|
54
|
+
print("â [MetaMapCapacitor] verificationCancelled")
|
|
55
|
+
print(" âĸ identityId: \(identity)")
|
|
56
|
+
print(" âĸ verificationId: \(verification)")
|
|
57
|
+
|
|
58
|
+
output?.reject(
|
|
59
|
+
"Verification was cancelled by the user",
|
|
60
|
+
"verificationCancelled",
|
|
61
|
+
nil,
|
|
62
|
+
[
|
|
63
|
+
"identityId": identity,
|
|
64
|
+
"verificationId": verification,
|
|
65
|
+
"status": "cancelled"
|
|
66
|
+
]
|
|
67
|
+
)
|
|
50
68
|
}
|
|
51
69
|
|
|
52
70
|
public func verificationCreated(identityId: String?, verificationID: String?) {
|
|
53
|
-
|
|
71
|
+
let identity = identityId ?? "nil"
|
|
72
|
+
let verification = verificationID ?? "nil"
|
|
73
|
+
print("đĄ [MetaMapCapacitor] verificationCreated")
|
|
74
|
+
print(" âĸ identityId: \(identity)")
|
|
75
|
+
print(" âĸ verificationId: \(verification)")
|
|
54
76
|
|
|
55
77
|
notifyListeners("verificationCreated", data: [
|
|
56
|
-
"identityId":
|
|
57
|
-
"verificationId":
|
|
78
|
+
"identityId": identity,
|
|
79
|
+
"verificationId": verification
|
|
58
80
|
])
|
|
59
81
|
}
|
|
60
82
|
}
|