metamap-capacitor-plugin 4.0.2 → 4.0.3

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.
@@ -13,6 +13,6 @@ Pod::Spec.new do |s|
13
13
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
14
  s.ios.deployment_target = '13.0'
15
15
  s.dependency 'Capacitor'
16
- s.dependency 'MetaMapSDK', '3.13.1'
16
+ s.dependency 'MetaMapSDK', '3.14.2'
17
17
  s.swift_version = '5.1'
18
18
  end
@@ -51,7 +51,7 @@ dependencies {
51
51
  implementation fileTree(dir: 'libs', include: ['*.jar'])
52
52
  implementation project(':capacitor-android')
53
53
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
54
- implementation ('com.metamap:android-sdk:3.29.1')
54
+ implementation ('com.metamap:android-sdk:3.32.0')
55
55
  }
56
56
 
57
57
 
@@ -15,6 +15,11 @@ import com.metamap.metamap_sdk.Metadata;
15
15
  import org.json.JSONObject;
16
16
  import org.json.JSONException;
17
17
 
18
+
19
+ import java.util.Iterator;
20
+
21
+ import android.graphics.Color;
22
+
18
23
  @CapacitorPlugin(name = "MetaMapCapacitor")
19
24
  public class MetaMapCapacitorPlugin extends Plugin {
20
25
 
@@ -30,14 +35,41 @@ public class MetaMapCapacitorPlugin extends Plugin {
30
35
  final String flowId = call.getString("flowId");
31
36
  final JSONObject metadata = call.getObject("metadata", new JSObject());
32
37
  try {
33
- metadata.put("sdkType", "capacitor");
34
38
  if (clientId == null) {
35
- Log.e("MetaMapCapacitorPlugin", "\"Client Id should be not null\"");
39
+ Log.e("MetaMapCapacitorPlugin", "\"Client Id should be not null\"");
36
40
  } else {
37
- Intent flowIntent = MetamapSdk.INSTANCE.createFlowIntent(bridge.getActivity(), clientId, flowId, Metadata.fromJson(metadata.toString(2)));
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);
38
70
  startActivityForResult(call, flowIntent, "callback");
39
71
  }
40
- } catch(JSONException excepion) {
72
+ } catch(Exception excepion) {
41
73
  call.reject("Verification failed");
42
74
  }
43
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metamap-capacitor-plugin",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Capacitor plugin for MetaMapSDK",
5
5
  "main": "dist/plugin.js",
6
6
  "module": "dist/esm/index.js",