Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this repo officially inactive ? #301

Open
adkaushik opened this issue Oct 31, 2019 · 4 comments
Open

Is this repo officially inactive ? #301

adkaushik opened this issue Oct 31, 2019 · 4 comments

Comments

@adkaushik
Copy link

In react native version 0.60, this library does not seem to work, since react native moved webview from the core in to a separate repo.

Are there any plans to upgrade this library aswell?

@fungilation
Copy link
Contributor

Move on and migrate to https://github.com/react-native-community/react-native-webview, I have. It has all functionality this library has, + WKWebView on iOS for performance and more. And far more actively developed

@ahmadalfy
Copy link

@fungilation seem that it's fully compatible except for the method onBridgeMessage should be replaced with onMessage.

@aneena-thomas
Copy link

@ahmadalfy How to get data from a form if I submit a form offline in react-native-webview. Because webviewbridge return some response offline but does not get any response from react-native-webview.

And when I this library I have one script like this,
export default function submissionScript(formId, previousResponseId = 'none', previousResponseCreated = 'none') {

let string = `<script>
function prepBridge() {
window.ReactNativeWebView.postMessage = function (message) {
var resultDiv = document.getElementById("theForm");
if(message === "responseSaved")
resultDiv.innerHTML = 'Your response has been stored successfully.';
if(message === "cachedResponseSubmitted")
resultDiv.innerHTML = 'Your submission has been submitted.';
}
}
async function readUploadedFileAsBinary(inputFile) {
const temporaryFileReader = new FileReader();

return new Promise((resolve, reject) => {
  temporaryFileReader.onerror = () => {
    temporaryFileReader.abort();
    window.ReactNativeWebView.postMessage(JSON.stringify({ type: error, msg: "A file error occured" }));
  };

  temporaryFileReader.onload = () => {
    resolve(temporaryFileReader.result);
  };
  temporaryFileReader.readAsBinaryString(inputFile);
});

};

async function grabSubmission()
{
let formId = ${formId}, previousResponseId = '${previousResponseId}', previousResponseCreated = '${previousResponseCreated}';
var fileResults = [], fileElementIds = [];
let hasFiles = false, hasSelectLists = false;

prepBridge();

let fileElements = document.querySelectorAll("#theForm input[type=file]");

if(fileElements.length > 0) {
    hasFiles = true;
    for (var i=0; i < fileElements.length; i++) {
        let thisResult = {};
        var fileElementFile = fileElements[i].files[0];
        console.log(fileElements[i].files[0]);
        fileElementIds.push(fileElements[i].id);

        if(fileElementFile) {
            thisResult.contents = await readUploadedFileAsBinary(fileElementFile);
            thisResult.fieldId = fileElements[i].id;
            thisResult.filename = fileElementFile.name;
            fileResults.push(thisResult);
        }
    }
}

if(wFORMS.instances.esignature > 0) {
    var instances = wFORMS.instances.esignature;

    for (var i = 0; i < instances.length; i++) {
        instances[i].exportSignature();
        instances[i].exportInitials();
    }
}

var form = document.getElementById('theForm');
let formData = new FormData(form);
let basic_form_data = [], select_lists = [];

for(var pair of formData.entries()) {
    if(pair[0].indexOf('[]') > 0) {
        hasSelectLists = true;
        select_lists.push({
            id: pair[0].replace("[]", ""),
            value: pair[1]
        });
    }
    else if(!fileElementIds.includes(pair[0]))
        basic_form_data.push({ inputName: pair[0], value: pair[1] });
};

if (WebViewBridge)
  window.ReactNativeWebView.postMessage(JSON.stringify({ type:'response',
  response: { basic_form_data, select_lists, previousResponseId, previousResponseCreated, hasSelectLists, hasFiles, fileResults, formId } }));

}
</script>`;

return string;

}

So this will return the response offline.

@ahmadalfy
Copy link

@aneena-thomas sorry, no clue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants