Can I do long running background uploads with a Cordova plugin?


#1

I’m building a prototype of an iOS 8 app with Ionic that needs native code for 2 features:

  1. background upload of photos by dateTaken, could be a large number of photos
  2. a custom view of the Camera Roll that allows browsing of thumbnails by date

Can I achieve both these goals through Cordova Plugins? I’m scanning the docs for Cordova Plugins and a couple of red flags pop up

Plugin Initialization & Lifetime
Plugins with long-running requests, background activity (e.g. playing media), listeners or internal state should implement the onReset method and stop or clean up those activities. This method is run when the UIWebView navigates to a new page or refreshes, which reloads the Javascript.

Issue 1: I need to be able to set the background process (or a “notification”) to wake on a future date and check for photos taken on that day. Then it needs to be able to complete the upload process in the background. The onReset method seems to run counter to this goal.

Issue 2: I need to let the user scroll through all the photos in their Camera Roll smoothly & quickly. I know I can write a plugin that loads its own independent View, much like the cordova.camera plugin. But is it possible to append this view inside a WebView, like an iframe?

If I can use cordova plugins for these features, then I can reuse my ionic ‘prototype’. Otherwise, I’m afraid I’ll have to build the whole app native.


#2

hello,
may be you can :

  • Register some event listeners in onDeviceReady [function()]

Sample :
// Register event listener, to know if application is in background
document.addEventListener(“pause”, onAppPause, false);
// Register event listener, will be fire when the app is back in foreground
document.addEventListener(“resume”, onAppResume, false);

and then,

// Call this when the app is moved to background
function onAppPause(){

}

// Call this when the app is moved to foreground
function onAppResume(){

}

wish help
++