I have used the system notification plugin from the github(https://github.com/saileshmittal/phonegap-system-notification-plugin) for android phonegap.I have used this code in my index.html
My code is:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var not_title = 'Message';
var not_text = 'Zou dit werken?';
var not_tText = 'Message';
navigator.systemNotification.onBackground();
navigator.systemNotification.onForeground();
navigator.systemNotification.createStatusBarNotification(not_title, not_text, not_tText);
}
I got the notification icon in both foreground and background.But is it possible to run the whole application to run in the background when the button is clicked in the application and call my wcf services continuously.Also i need to get the alert even when running in the background.how to do that?
navigator.systemNotification.onBackground()
:this line run the application in background or not other wise it only for showing the notification after closing the application.
please guide me,thanks in advance.
I made an Android application with PhoneGap and when I press the home button, my application stays in background (with my last test it stays more than 1 hour). But when I launch other App the Android OS kills my application.
To enable this behaviour you need to add the android permission:
<uses-permission android:name="android.permission.WAKE_LOCK" />
to your manifest
and you also need to add:
<preference name="exit-on-suspend" value="false" />
to your config.xml
in folder res/xml
I hope this post can you help you :)
According to the phonegap documentation you cannot run the apps in the background, the js cannot continue to run. The reason notifications are able to work is because they are using the native system to send the notifications.
In order to make processes run in the background you will need to create a plugin that uses the native os.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With