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

Fixes Issue #11 (and 20) #28

Merged
merged 1 commit into from
Oct 20, 2016
Merged

Conversation

Daxito
Copy link
Contributor

@Daxito Daxito commented Oct 14, 2016

Fixes issue #11 , #20 and #27

@JaganJonnala
Copy link

HI @Daxito ..... IN my node_modules > NativeScript-background-http folder i have background-http.android.js file .. by replacing with your code with .ts file its showing some error can you have any other way

@JaganJonnala
Copy link

image

Is any need to change with folder structure or any commands to run

@Daxito
Copy link
Contributor Author

Daxito commented Oct 15, 2016

@JaganJonnala What error you mean? the line of code I added are the same for ts file or js file (the two lines of code I added), do you mean that red underline? just ignore them and test it out to see if it works for you, no other changes required.
oh, and make sure you tns platform remove android and tns platform add android

@Daxito
Copy link
Contributor Author

Daxito commented Oct 15, 2016

Well, if js file then it should be var utils = require("utils/utils");.

@JaganJonnala
Copy link

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

Error calling module function

Error calling module function

Error calling module function

TypeError: Cannot read property 'gotev' of undefined
File: "/data/data/org.nativescript.myapp/files/app/tns_modules/nativescript-background-http/background-http.js, line: 11, column: 24

StackTrace:
Frame: function:'', file:'/data/data/org.nativescript.myapp/files/app/tns_modules/nativescript-background-http/background-http.js', line: 11, column: 25
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.myapp/files/app/app.component.js', line: 4, column: 14
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.myapp/files/app/main.js', line: 5, column: 23
Frame: function:'require', file:'', line: 1, column: 266

TypeError: Cannot read property 'gotev' of undefined
File: "<un

@JaganJonnala
Copy link

@Daxito Showing this error .... I have Written as

var net;
var servicePackage = net.gotev.uploadService;

@JaganJonnala
Copy link

@Daxito

Getting this error while uploading image

java.lang.RuntimeException: Error receiving broadcast Intent { act=net.gotev.uploadservice.broadcast.status flg=0x10 (has extras) } in com.tns.gen.net.gotev.uploadservice.UploadServiceBroadcastReceiver_ftns_modules_nativescript-background-http_background-http_l6_c70__@66ab662
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:891)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.tns.NativeScriptException:
Calling js method onError failed

TypeError: Cannot read property 'push' of undefined
File: "/data/data/org.nativescript.myapp/files/app/app.component.js, line: 43, column: 23

StackTrace:
Frame: function:'log

@JaganJonnala
Copy link

My Code:

uploadHttp(fileUri) {
        let imageName = this.extractImageName(fileUri);
        var request = {
            url: "http://192.168.1.5:8083",
            method: "POST",
            headers: {
                "Content-Type": "application/octet-stream",
                "File-Name": imageName
            },
        };
        console.log("Uploading Image---------------------");
        console.log("Image Name********", imageName);
        console.log("File URI********", fileUri);
        // console.log("request", JSON.stringify(request));

        var task = session.uploadFile(fileUri, request);
        function logEvent(e) {
            this.events.push({
                eventTitle: e.eventName + " " + e.object.description,
                eventData: JSON.stringify({
                    error: e.error ? e.error.toString() : e.error,
                    currentBytes: e.currentBytes,
                    totalBytes: e.totalBytes
                })
            });
            console.log("e------", JSON.stringify(e));
            console.log(e.eventName);
        }

        task.on("progress", logEvent);
        task.on("error", logEvent);
        task.on("complete", logEvent);


    }


@Daxito
Copy link
Contributor Author

Daxito commented Oct 17, 2016

Maybe your this.events variable is not defined, are you sure you have it defined somewhere? if so try not to use this

@PanayotCankov PanayotCankov merged commit b06d761 into NativeScript:master Oct 20, 2016
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

Successfully merging this pull request may close these issues.

None yet

3 participants