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

App Crash if formatString is Array (iOS) #255

Open
two-bridges opened this issue Feb 9, 2021 · 0 comments
Open

App Crash if formatString is Array (iOS) #255

two-bridges opened this issue Feb 9, 2021 · 0 comments

Comments

@two-bridges
Copy link

If you pass an array to format attribute, the app running on a physical iOS device will crash.

eg. [formats]="['QR_CODE']"

Error: formatsString.split is not a function

It was my error to try to send an array, but it was very painful to solve this issue in a production app.

I guess it could throw an ugly error but best if it did not to crash the whole app.

Possible Solution:

add typeof formatsString before trying to use formatsString, as shown below:

/node_modules/nativescript-barcodescanner/barcodescanner.ios.js

const getBarcodeTypes = (formatsString) => {
    const types = [];
    if (typeof formatsString === "string" && formatsString) {
        let formats = formatsString.split(",");
        for (let format of formats) {
            format = format.trim();
            if (format === "QR_CODE")
@two-bridges two-bridges changed the title App Crash if formatString is not string (iOS) App Crash if formatString is Array (iOS) Feb 9, 2021
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

1 participant