Giter Site home page Giter Site logo

Comments (14)

tomshabtay avatar tomshabtay commented on June 20, 2024 2

I edited the the background-http.android.ts file once again and made the notification disappear completely.

Please consider adding this functionally to your plugin in your next update.

Thanks!

The change that i made was to comment this section:
var displayNotificationProgress = typeof options.androidDisplayNotificationProgress === "boolean" ? options.androidDisplayNotificationProgress : true; if (displayNotificationProgress) { request.setNotificationConfig(new (<any>net).gotev.uploadservice.UploadNotificationConfig()); }

from nativescript-background-http.

tsonevn avatar tsonevn commented on June 20, 2024

Hi @farzeni,
I reviewed your case on my side, however, at this time there is no appropriate way to set up this options from code behind.

Regarding that, I log this issue as a new feature.

In the meantime, I could suggest setting those options inside the background-http.android.ts file as you have mentioned and to create your local tgz, which you could use in your project. You could follow the below-attached steps.

  1. git clone https://github.com/NativeScript/nativescript-background-http
  2. add in nativescript-background-http/background-http.android.ts file following settings inside the create method.
 static create(session: Session, file: string, options: common.Request): Task {
        var task = new Task();
        task._session = session;
        task._id = session.id + "{" + ++Task.taskCount + "}";

        var context = application.android.context;

        var request = new (<any>net).gotev.uploadservice.BinaryUploadRequest(context, task._id, options.url);

        request.setFileToUpload(file);

        request.setNotificationConfig(new (<any>net).gotev.uploadservice.UploadNotificationConfig());
        request.setFileToUpload(file);
        request.setRingToneEnabled(false);
        var headers = options.headers;
        if (headers) {
            for (var header in headers) {
                var value = headers[header];
                if (value !== null && value !== void 0) {
                    request.addHeader(header, value.toString());
                }
            }
        }
  1. npm install
    4, npm run tsc
  2. npm pack

the newly created tgz file could installed with tns plugin add <path to the file>

from nativescript-background-http.

dvdbrk avatar dvdbrk commented on June 20, 2024

Umm... I don't think this works, I get

JS: ERROR TypeError: request.setRingToneEnabled is not a function

from nativescript-background-http.

tomshabtay avatar tomshabtay commented on June 20, 2024

Hi, i also tried your suggested fix and got the same error.
TypeError: request.setRingToneEnabled is not a function

from nativescript-background-http.

geoffbullen avatar geoffbullen commented on June 20, 2024

+1

from nativescript-background-http.

bniehuser avatar bniehuser commented on June 20, 2024

if you read the code you commented out, you will realize you can include the boolean flag 'androidDisplayNotificationProgress' in the options array passed to either 'uploadFile' or 'multipartUpload' (set to false to omit the notification).

thanks for pointing it out, looking at this thread is what finally made that option and its use click. :)

from nativescript-background-http.

geoffbullen avatar geoffbullen commented on June 20, 2024

@bniehuser - Thank you for pointing that out!

from nativescript-background-http.

andreasteffanoni avatar andreasteffanoni commented on June 20, 2024

+1

from nativescript-background-http.

geoffbullen avatar geoffbullen commented on June 20, 2024

@bniehuser note this doesn't appear to work for recent android versions. See #148

from nativescript-background-http.

AradhanaR avatar AradhanaR commented on June 20, 2024

Currently I am facing two issues with the plugin :

  • I am using nativescript-imagecropper with nativescript-background-http and it was working properly before updating the plugin nativescript-background-http to latest version and nativescript to 4.1.0 . But now app crashes with following error:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Error receiving broadcast Intent { act=com.proxible.innercircle.uploadservice.broadcast.status flg=0x10 pkg=com.proxible.innercircle (has extras) } in net.gotev.uploadservice.UploadServiceBroadcastReceiver_http_91_87_@61a749f
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_53427(LoadedApk.java:1356)
at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.$m$0(Unknown Source:4)
at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.run(Unknown Source:0)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6798)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: com.tns.NativeScriptException:
Calling js method onCompleted failed

  • Another issue is that I need to disable upload notification on android but options.androidDisplayNotificationProgress is no longer available in recent version and above suggestions are not working.

Please suggest solutions asap.

from nativescript-background-http.

marcossaore avatar marcossaore commented on June 20, 2024

@tomshabtay, Would you have this file updated.? I wanted to copy it. Do you know about any course that explains how to create plugins, sometimes I need change something on code but give up on the same time because of complexity of them.

from nativescript-background-http.

tomshabtay avatar tomshabtay commented on June 20, 2024

@manoldonev i used tsonevn explanation in this thread to edit the plugin.
I uploaded the edited plugin I used
nativescript-background-http-3.1.0.zip

from nativescript-background-http.

VladimirAmiorkov avatar VladimirAmiorkov commented on June 20, 2024

This feature has been implemented is merged with #239

from nativescript-background-http.

zbranzov avatar zbranzov commented on June 20, 2024

Released in [email protected]

from nativescript-background-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.