How to always run app on background even if it was closed? (SERVICE)


#1

Hello everyone!
How to create service which will pinging remote $http and download remote file if it was setted up on remote API even if my app was closed. Run as service on background.


#2

up the question.
Is there any solution ?


#3

I solved this problem :


#4

Thank you for response


#5

It is when the app is in background… But how to run any function even when the app is closed?


#6

For now there is no ways to make this happen.
But I think we need look deeper at
https://github.com/driftyco/ionic-native plugin


#7

@cybernatic Thankyou for your response… Actually I’m trying to do a upload of the photo and some information to server like the way of uploading a photo in facebook…but while uploading ,if the app is closed it is failed. I want that functionality to achieve this need


#8

@karthik123 Did you manage to get that functionality working? I need the same


#9

Nope @antonfire. We need to write our own service and we have to do through that it seems. But i didn’t got a perfect solution. For now I kept it a side will update you if I found any. Please let me know if you find it .


#10

@karthik123 I’m not sure that will help, if going into background means javascript is paused then what is the point of the plugin? Do you mean we need to write a new cordova plugin as this one does not allow javascript to keep running in the background? Thanks Ant

See… https://github.com/katzer/cordova-plugin-background-mode/issues/146 to see what I’m trying to do, I think it’s similar to you.


#11

@antonfire That background plugin start works only when the app goes to background, If we start uploading where can we keep our code . Here the ambiguity arises. With the info I got, we need to write a android service in which the upload code should be present in that service. When we click a button the upload should move into that service, Its kind of a plugin we need to write on our own. I tried cordova background plugin but it wont work for our requirement.