How to run app forever in background like whatsapp?

how to run app forever in background like whatsapp ??

6 Likes

I use this plugin for my application.

https://github.com/katzer/cordova-plugin-background-mode

1 Like

thats not work if i close the app it will not run on background it will close forever i need to run myapp without launching my application

You can try to put your application in the background with this above plugin and its methods when the onPause event is fired. The event is provided from the Cordova device plugin. Another option is to create a service application that will run in the background but this cannot be achieved with Cordova. You’d need to use Java and build something like this.

Please be aware, to activate the background mode the app needs to be in foreground.

/**

  • Enables the background mode. The app will not pause while in background.
    */
    window.plugin.backgroundMode.enable();
1 Like

k if we are close the app mean it wil not in background permenently…i need to run after even close my app also

You must write a service, but I do not think this is possible with Cordova. As reported by raphaellop

is der any idea about that services ??

You can take a look at this plugin: https://github.com/Red-Folder/bgs-core
This plugin provides the core functionality for the Background Service Plugin for Cordova. But I’ve never used, there’s an related example if you want to test it.
The service remains active even when the application closes, all the logic must be written in Java.

i used that one too but all are same when i close all are destroy no service will run background …
even i follow that blog i dono wer did i misatake

Have you test the exemple?

yup i tested but it works when i resume the app it wil work in background if closed means it wil not run

I’ve mentioned handling events of cordova for pausing and resuming an app. Here is documentation:
http://cordova.apache.org/docs/en/3.5.0/cordova_events_events.md.html
The pause event is fired when app is put into background (usually when it is “closed”). Put your app into background then with the Katzer plugin mentioned by jimibi. Doesn’t this work?

I’m very interested in how you solve the issue. Please inform us :slight_smile:

A proper solution/official solution to this will be useful.

1 Like

To me you can solve this by using push messages. In particular Pushwoosh https://www.pushwoosh.com/

You can then send a message and when the user press the motivation the program will be opened.

pushwoosh is ther for android?? can you tell me how to use the plugin??

what do you want to do with the app in background? Messenger?

Btw Whatsapp works like this:

  1. User opens app

  2. App opens connection to there XMPP server

  3. App gets messages from the server.

  4. User leaves app (app is in background)

  5. App should still get the messages form server

  6. User closes app (app is shut down) background mode is also shut down.

  7. User gets messages over push notification (i think this is only to show the user hey you got a message)

  8. User opens app … see first step…

i think every message will be handled by the xmpp server.

and if i would build a chat/Messanger i would do it this way.

6 Likes

k i need to open app when bluetooth device will in my range and i need to do popup when ble device got matched tats my work thats it.

Which cordova plugin you ended up using for this scenario ? I have similar useless where I want to "wake up"the app when particular BLE device is in the range.

@Mishi have you founded a solution for your problem ? Thanks.