Giter Site home page Giter Site logo

nativescript-downloadmanager's People

Contributors

kazemihabib avatar polcpp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nativescript-downloadmanager's Issues

npm is not updated

Hey, I see there is a difference between the github version which has
downloadFile(url: string, options:DownloadOptions, cb: Function);
with lots of options in options. and the npm version has
downloadFile(url: string, cb: Function, directory?: string, filename?: string, title?: string, description?: string): void;

I installed it using:
tns plugin add nativescript-downloadmanager

Problem to download file!

My app is not on typescript, just plain javascript. Do I do it right? I can not download.

I try to download the url that is being sent to this function. But dm.downloadFile does not work. Console log "inside downfile" is not getting called.

var DownloadManager = require('nativescript-downloadmanager');
`
function DownloadFile(url) {
    let dm = new DownloadManager();
                                    
                                    dm.downloadFile(url, function(result,uri) {
                                        // result is a boolean, if the download was successful, it will return true
                                        console.log("********************************* inside downfile ****************");
                                        console.log(result);
                                        // Uri in file:// format of the downloaded file.
                                        console.log(uri);
                                        // unregisterBroadcast is used to unregister the broadcast (For example if you just want to 
                                        // download a single file).
                                        dm.unregisterBroadcast();
                                    })
}`

How to remove file after download?

Hi,

thank you for your plugin.

My question is: How to remove file after download.

I tried to return id of last downloaded file in:

//downloadmanager.android.js
if (this.downloads.has(id)) {
    var uri = c.getString(c.getColumnIndex(android.app.DownloadManager.COLUMN_LOCAL_URI));
    var cb = this.downloads.get(id);
    cb(success, uri, id);
}

and then in my callback:

dm.downloadFile("https://bohosluzby.cirkev.cz/uploads/church_service.db", function(result,uri, id) {
    console.log(id);
    dm.manager.remove(id)
}

but app crashes with error:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.DOWNLOAD_COMPLETE flg=0x10 pkg=org.nativescript.bohosluzbyapp (has extras) } in com.tns.gen.android.content.BroadcastReceiver_frnal_ts_helpers_l58_c38__BroadcastReceiver@41f5b9e8
	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:808)
	at android.os.Handler.handleCallback(Handler.java:808)
	at android.os.Handler.dispatchMessage(Handler.java:103)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:5292)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
	at dalvik.system.NativeStart.main(Native Method)
Caused by: com.tns.NativeScriptException: 
Calling js method onReceive failed

Error: Cannot convert number to [J at index 0
File: "file:///data/data/org.nativescript.bohosluzbyapp/files/app/services/churchservicedb.service.js, line: 141, column: 33

StackTrace: 
	Frame: function:'', file:'file:///data/data/org.nativescript.bohosluzbyapp/files/app/services/churchservicedb.service.js', line: 141, column: 34
	Frame: function:'DownloadManager.handleDownloadEvent', file:'file:///data/data/org.nativescript.bohosluzbyapp/files/app/tns_modules/nativescript-downloadmanager/downloadmanager.js', line: 46, column: 21
	Frame: function:'BroadcastReceiver.onReceive', file:'file:///data/data/org.nativescript.bohosluzbyapp/files/app/tns_modules/tns-core-modules/application/application.js', line: 217, column: 22


	at com.tns.Runtime.callJSMethodNative(Native Method)
	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
	at com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
	at com.tns.Runtime.callJSMethod(Runtime.java:1047)
	at com.tns.Runtime.callJSMethod(Runtime.java:1028)
	at com.tns.Runtime.callJSMethod(Runtime.java:1018)
	at com.tns.gen.android.content.BroadcastReceiver_frnal_ts_helpers_l58_c38__BroadcastReceiver.onReceive(android.content.BroadcastReceiver.java)
	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:798)
	... 9 more

Do you have a solution for deleting downloaded files after download is completed?

Thanks

Open downloaded file

Hi,

do you know how I could open downloaded file on android, I successfully download new apk version of the app and I would like to open it once its done, I tried doing custom intents, but I couldn't get it working.

thanks

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.