0

I'm doing an app with a part native and a part with html. I need to send the phone contacts to the html part, which later parse the JSON passed to a json object in Javascript with JSON.parse. Sometimes, it fails and I don't have anyway to know in which contact is failing.

Some advice to know the error? In Android or in javacript, thank you.

JS parse

return new Promise((resolve, reject) => {
  (<any>window).contactsOk = function (contacts) {
    try {
      const data = JSON.parse(contacts);
      resolve(data);
    } catch (error) {
      console.log('Error parsing contacts info', error);
      reject(error);
    }
  }
Víctor Martín
  • 3,352
  • 7
  • 48
  • 94

1 Answers1

1

Please check this post Passing a JavaScript object using addJavascriptInterface() on Android

You can pass as primitive and String. Avoid passing JSON object to JavaScript Convert Json object to String and then send

KIRAN CSN
  • 121
  • 9