Skip to content

Commit

Permalink
Fixed issue with metadata on android
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksei-klyshnikov-mati committed Dec 1, 2021
1 parent 0c86d6c commit ca17d87
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package space.serenity.mati.capacitor;
package com.getmati.plugins.capacitor;

import android.app.Activity;
import android.content.Intent;
Expand All @@ -12,12 +12,12 @@
import com.getcapacitor.PluginMethod;
import com.getcapacitor.annotation.ActivityCallback;
import com.getcapacitor.annotation.CapacitorPlugin;
import com.getmati.mati_sdk.MatiButton;
import com.getmati.mati_sdk.MatiSdk;
import com.getmati.mati_sdk.Metadata;
import com.getmati.mati_sdk.ui.data_prefetch.DataPrefetchActivity;

import org.json.JSONObject;
import org.json.JSONException;

@CapacitorPlugin(name = "MatiCapacitor")
public class MatiCapacitorPlugin extends Plugin {
Expand All @@ -32,22 +32,21 @@ public void run() {

final String clientId = call.getString("clientId");
final String flowId = call.getString("flowId");
final JSObject metadata = call.getObject("metadata", null);
metadata.put("sdkType", "capacitor");
final JSONObject metadata = call.getObject("metadata", new JSObject());
try {
metadata.put("sdkType", "capacitor");

Intent intent = new Intent(bridge.getActivity(), DataPrefetchActivity.class);
Intent intent = new Intent(bridge.getActivity(), DataPrefetchActivity.class);

intent.putExtra("ARG_CLIENT_ID", clientId);
if(flowId != null) {
intent.putExtra("ARG_FLOW_ID", flowId);
intent.putExtra("ARG_CLIENT_ID", clientId);
if (flowId != null) {
intent.putExtra("ARG_FLOW_ID", flowId);
}
intent.putExtra("ARG_METADATA", Metadata.fromJson(metadata.toString(2)));
startActivityForResult(call, intent, "callback");
} catch(JSONException excepion) {
call.reject("Verification failed");
}
if(metadata != null) {
intent.putExtra("ARG_METADATA", metadata.toString());
}

// MatiSdk.INSTANCE.startFlow(bridge.getActivity(), clientId, flowId, Metadata.fromJson(metadata.toString()));

startActivityForResult(call, intent, "callback");
}
});
}
Expand Down

0 comments on commit ca17d87

Please sign in to comment.