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

[@nativescript/background-http] iOS 14 compatibility #30

Closed
relez opened this issue Oct 15, 2020 · 8 comments
Closed

[@nativescript/background-http] iOS 14 compatibility #30

relez opened this issue Oct 15, 2020 · 8 comments

Comments

@relez
Copy link

relez commented Oct 15, 2020

I am having an issue with iOS 14 where if I try to upload multiple files the app crashes, I was able to verify and the images are being uploaded, but looks like the app crashes when it tries to execute the events:

task.on("progress", onUploadProgress);
task.on("error", onUploadError);
task.on("complete", onUploadCompleted);

Here is my console logs:

***** Fatal JavaScript exception - application has been terminated. *****
NativeScript encountered a fatal error: Uncaught Error: -[NSInvocation getArgument:atIndex:]: NULL address argument
at
readProp(file: node_modules/@nativescript/background-http/index.ios.js:218:0)
at get upload(file: node_modules/@nativescript/background-http/index.ios.js:235:0)
at onProgress(file: node_modules/@nativescript/background-http/index.ios.js:7:0)
at push.../node_modules/@nativescript/zone-js/zone-nativescript.js.ZoneDelegate.invoke(file: node_modules/@nativescript/zone-js/zone-nativescript.js:388:0)
at push.../node_modules/@nativescript/zone-js/zone-nativescript.js.Zone.runGuarded(file: node_modules/@nativescript/zone-js/zone-nativescript.js:151:0)
at (file: node_modules/@nativescript/zone-js/zone-nativescript.js:129:0)
at (file: node_modules/@nativescript/background-http/index.ios.js:78:0)
(CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Uncaught Error: -[NSInvocation getArgument:atIndex:]: NULL address argument
at
readProp(file: node_modules/@nativescript/background-http/index.ios.js:218:0)
at get upload(file: node_modules/@nativescript/background-http/index.ios.js:235:0)
at onProgress(file: node_modules/@nativescript/background-http/index.ios.js:7:0)
at push.../node_modules/@nativescript/zone-js/zone-nativescript.js.ZoneDelegate.invoke(file: node_modules/@nativescript/zone-js/zone-nativescript.js:388:0)
at push.../node_modules/@nativescript/zone-js/zone-nativescript.js.Zone.runGuarded(file: node_modules/@nativescript/zone-js/zone-nativescript.js:151:0)
at (file: node_modules/@nativescript/zone-js/zone-nativescript.js:129:0)
at (file: node_modules/@nativescript/background-http/index.ios.js:78:0)
', reason: '(null)'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff2043a126 __exceptionPreprocess + 242
1   libobjc.A.dylib                     0x00007fff20177f78 objc_exception_throw + 48
2   NativeScript                        0x0000000104cee344 _ZN3tns21NativeScriptException15OnUncaughtErrorEN2v85LocalINS1_7MessageEEENS2_INS1_5ValueEEE + 914
3   NativeScri<…>

Also the single file upload does not work either, it does nothing.

@relez relez changed the title [background-http] iOS 14 compatibility [@nativescript/background-http] iOS 14 compatibility Oct 15, 2020
@bellalMohamed
Copy link

Facing same issue

@marcocasadio
Copy link

marcocasadio commented Oct 16, 2020

Same issue for me. I'm using Vue. My code with NS6 worked correctly.

I’m using @nativescript/background-http with NS7 and Vue. I’m following the demo but I get an error when I upload (let task = sess.multipartUpload(params, request)) and I don’t understand how fix it.

Error:

***** Fatal JavaScript exception - application has been terminated. *****
NativeScript encountered a fatal error: Uncaught Error: -[NSInvocation getArgument:atIndex:]: NULL address argument
at 

Code:

let urlString = parseComplexEndpoint(api.endpoints['tc_list'], [this.tr.id, this.ts.id]);
            let sess = session("file-upload");
            let request = {
                url: urlString,
                method: "POST",
                headers: {
                    "Authorization": 'Bearer ' + apiToken(),
                    "Content-Type": "multipart/form-data",
                }
            };
            let params = [
                {
                    name: "body",
                    value: this.message
                }
            ];
            if (this.attachments && this.attachments.length > 0) {
                this.attachments.forEach((item) => {
                    if (item.file && item.file != '') {
                        params.push(
                            {
                                name: this.getFilenameAndExtention(item.file),
                                filename: item.file.replace("file://","")
                            }
                        );
                    }
                });
            }
            console.log("multipartUpload request", JSON.stringify(request));
            console.log("multipartUpload params", JSON.stringify(params));
            this.loading = true;
            let task = sess.multipartUpload(params, request);
            task.on("error", (e) => {
                console.log("upload error", JSON.stringify(e));
                alert("error received " + e.responseCode + " code.");
            });
            task.on("responded", (e) => {
                console.log("responded", JSON.stringify(e) );
                console.log("responded data", JSON.stringify(e.data) );
                // alert("responded received " + e.responseCode + " code. Server sent: " + e.data);
            });
            task.on("complete", (e) => {
                // alert("complete received " + e.responseCode + " code");
                console.log("upload complete", JSON.stringify(e));
                this.loading = false;
                if (e.responseCode >= 200 && e.responseCode < 300) {
                    this.$store.commit('showFeedback', {
                        type: 'success',
                        message: 'Reply added correctly',
                    });
                    this.$navigateBack();
                } else {
                    this.$store.commit('showFeedback', {
                        type: 'error',
                        message: 'Error with ' + e.responseCode + ' code',
                    });
                }
            });

Before upgrade to NS7 it works correctly

@relez
Copy link
Author

relez commented Oct 19, 2020

Hey there, is there any update on this issue? I am being bombarded by my clients regarding this problem. Thanks!

@kourtzaridisr88
Copy link

Same issue here!

@relez
Copy link
Author

relez commented Oct 29, 2020

Is there any plan to fix this issue? Thanks!

@marcocasadio
Copy link

@relez @kourtzaridisr88 this is a workaround
NativeScript/nativescript-background-http#270
it works for me! waiting for the official fix.
thanks

@JWiseCoder
Copy link

I'm also having this issue. Waiting on the official fix.

@NathanWalker
Copy link
Contributor

Published in 5.0.1 thanks to @boutier

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

6 participants