I have created an iPhone application using phoneGap and i have implemented the Websync functionality using javascript, all functionality are working fine,
but my problem is that When Iphone goes to sleep mode than the app is still open and when you wakeup the phone websync doesnt work anymore.
Generally speaking iOS apps are not allowed to maintain a permanent connections in the background.
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
Keep in mind the following about inactive apps:
Inactive
The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state.
iOS (and other mobile devices) don't allow JavaScript to run in the background when the device is sleeping. Battery life would suffer tremendously if it did.
However, WebSync 4 should automatically re-connect to the server after waking up. If you are using WebSync 3, you have to set a flag (stayConnected) to get the same behaviour:
client.connect({ stayConnected: true }); // WebSync 3 only
Related
I'm developing a simple app with phonegap which every 30 seconds send user current coordinates to my database via ajax call.It works very well
$(document).ready(function() {
setInterval(function() {
SetLocationUpdates();
}, 30000);
});
but if the user navigates to another app(google maps app) or if I open google maps app with this code
<div><a href="geo:41.897096,27.036545">Open maps app</div>
it(sending coordinates to my database via ajax) fails because getCurrentPosition does not work maybe google maps lock it althoug my app is still work(my app and google map app work separately.Two apps work at same time.Maybe my app go background)
More specifically, it does nothing.
navigator.geolocation.getCurrentPosition(SetLocationUpdates, onError);
this line not execute.
The success or error callbacks are never called, and setting a timeout does not affect this. I am using Phonegap Build to compile the app from html and javascript.
What should I do?
You need a native background geolocation solution - JS execution on the main thread gets paused when your app goes into the background.
In my experience, the most resilient solution is cordova-background-geolocation-lt. I've tested on multiple OS versions, including Android 8 and iOS 11, and this has worked consistently on all.
Please be aware that Firefox currently continues to work when the phone is asleep or the App is backgrounded. (I believe this is a bug)
IMHO the most appropriate and battery friendly solution relies on ServiceWorkers receiving and actioning TravelEvents from the TravelManager.
See this Web App for proof of how well Background geolocation fits with ServiceWorker infrastructure. All source can be found here including a aaa_readme.txt.
Please ask W3C/IETF to standardize this and your UA vendors to implement it!
I developed a web app to display a slideshow, and want to display it on my secondary monitor (Connected via HDMI) with IE's Kiosk mode on Windows 10. Because of CPU and other resources on the shared server, I want to pause the slideshow when the monitor is powered off. (And therefore nobody is seeing it)
Is there a way to detect connected displays from Internet Explorer? Since this is a one-pc kiosk setup, add-ons, etc. are accepted. Triggering javascript/jquery events would be ideal. Thank you!
No, there is no reliable way to detect if a second monitor is physically switched off but still connected via the cable.
I have to ask though: why do you need to physically switch the second monitor off?
As an alternative could you not:
Have the slideshow stop after a timed duration unless it receives an input?
Have the slideshow only on display at certain times of the day?
Accept events from, say, a node server to control when to and not show the slideshow?
Having said that these threads could provided you, albeit unreliably apparently, what you need:
Is there any way to detect the monitor state in Windows (on or off)?
Monitoring a displays state in python?
You can't do in javascript. Why not try some asp component.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162617%28v=vs.85%29.aspx
You could potentially write a command line program that sits on a particular port, continuously checks for that locally and then use HTML5 WebSockets in IE to communicate with it?
i.e. C# PowerModeChangedEvent
SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(
SystemEvents_PowerModeChanged
);
I don't think so....
CPU cycles are paused when the client computer is put into Sleep mode. (win+L)
Start>Control Panel>Power
configures how the monitor(s) behave when the client is powered down or put to sleep mode.
the screen object in js returns the metic values (height/width) of the screen object but not its powered state.
the impact of wasted CPU cycles on a powered down secondary monitor should be un-noticable....
probably you have not selected the option to "Use software rendering instead of GPU rendering" on the Advance tab of internet options....
You will notice that your CPU on your desktop will throttle up and the cooling fan will race if you haven't set the above setting when running graphic intensive web pages or canvas scripts.
Good morning
I'm developing a cordova application for my internship.
The application tracks the position of the user and does some logic with it to generate data the user needs.
This all works fine but the application needs to run as long as the user has a button on the main screen enabled
but right now when the application is running and you enabled the button which makes the application track the data. Then when the screen is turned off the application gets turned off and doesnt track the users position anymore.
I presume the application is suspended but then when you open the application again it is like you opened the application for the first time. (button turned off)
Is there a way to keep the application active? i know in native android you can write a service which does this but i need something that works with cordova
thanks in advance for the help
regards
bavo
I'm developing a web app that shows a counter, and when the counter comes down to 0 I want to notify the user(The counter is on a server, so there won't be a problem with reloading the page).
If the user is on a computer, I'm using a popup for the notification, but if the user is on an Android device, I would like the notification to be shown even if the browser isn't open.(I'm using AngularJS if that would be any help)
Is there a way to do this? I rather not build a special Android app.
Thanks.
//G
I'm afraid no, there is no way to do that. When any android application is not active is... not active, frozen. The browser is not a service, so as far as I know it won't process anything while in background. Even it's possible the OS close the browser if it needs more memory than is available.
I have a web application (HTML5, CSS3, JQuery) that displays notifications using both methods: a growl-like jquery plugin (javascript+html), or using the Chrome notification API (only if you are using Chrome).
What I want is to create a javascript growl-like notification that is shown over all the other windows in the screen, even if you have another application focused in fullscreen mode.
I think that this is not possible with javascript because probably it is restricted to the browser window, but maybe with the Chrome notification API it could be done (this notifications popup over other applications, if they are not in fullscreen mode).
Recently Chrome updated its browser so that the notifications are not shown if you have an application in fullscreen. In general it is a good update but if you want to show the notification even if you are in a fullscreen app, how do you do that? Can the final user of the web application change the behaviour of this notifications and make them appear always?
PD: if there is another browser technology that allows this kind of notifications, please tell me.
As far as I am aware this is not possible, certainly not as any sort of cross-browser solution.