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!
Related
I have been searching how to solve this issue for a couple of days with no success, so I decided to open a question here. So I have got a React app which uses Redux and Firebase as a database. Everything loads ok in every desktop and mobile browser except Facebook's in app browser. When I open it through my phone their browser fires and gets the title, it loads the injected scripts from Netlify but does not execute any Javascript and I get a blank page.
I have also tried to prerender the app with React Snap and then my app loads, but never preloads the Javascript and therefore the loaded visible content only stays HTML and CSS and nothing Javascript related works.
I am asking for help since I really have no idea what is wrong. There was no errors on build and as I said on every other browser, the web app works.
I have generated the app with create-react-app.
If someone have any suggestions, that would be helpful!
Okay I found what caused the app not loading in Facebook's in app browser. The problem was due to the Notifications API and the fact that it is disabled there. My app was using it, therefore it crashed in the beginning and the bundle did not load at all. That is why I had a blank screen on the non prerendered version and no javascript on the prerendered. Both ways there was no JS loaded because of this. So now I just check if the user agent supports the API and run my functions accordingly. Hope it helps to someone with the same issue.
I am building a hybrid app, with AngularJS, Cordova, Restangular ond client side and Python with wsgiref.simple_server on server side. I am not doing anything special, this is very simply requests like this:
Restangular.one('/devices').get().then(function (response) {
viewModel.devices = Restangular.stripRestangular(response.devices);
});
I set baseUrl for Restangular:
.config(function(RestangularProvider){
RestangularProvider.setBaseUrl('http://192.168.54.102:8000/');
})
And when I use it on local computer with Chrome browser, everything is fast, works normal. But when I use it on Android on Phonegap developer app on device or install app on device with Android, it works crazy slow. It looks like it is send to server with big delay, cause it takes some time as I see debug server log on server side. It occurs also when python application with server is not in debug mode, for example when I start it normally after install on local computer. As I see some people has this problem, does anybody found a solution or a reason, which causes very slow HTTP requests in hybrid application? Thank you in advance for every answer.
Since you are a hybrid developer, I am sure you are familiar with the Chrome DevTools. For me on a Mac, hit cmd + option + i, or go to View -> Developer -> Developer Tools.
The really great thing about Chrome in recent history is it now works with Android WebViews too. Hybrid developers haven't always had this convenience, and had to debug essentially handcuffed using tools like Weinre.
Now we can use the DevTools directly in the Chrome browser while your Android device is connected by ADB from a new tab calling chrome://inspect
Here is some more detailed information on how to do this if you get stuck.
From here open up the network panel and see how long your requests are taking. If they are showing a significantly longer amount of time to load here, the issue has nothing to with Angular, Cordova, Restangular or probably even Hybrid architecture at all. I would check your network and performance elsewhere on the device.
If this is definitely not the issue, I would use the Timeline tab in the DevTools to see what is taking so long between your browser receiving the information and your device displaying it. If there is any significantly longer process taking place in between, you will see it here.
I am using Phonegap to develop an mobile app.
Unlike web application, an mobile app is a static client which is updated less frequently than expected. Moreover, version management is required to maintain the dependency between server and client end.
I am thinking about a way to make the mobile app more like a pure browser. And here is a potential solution.
The initial index.html in Phonegap app gets the latest version from server and compares the version number cached in the browser/WebView;
If the current version is behind the latest, it fetches the remote homepage and replaces the whole html document and caches the latest version number;
Pros:
No more need to publish new version of mobile apps;
All platforms (mobile and web) use the latest version, no more manual update is required;
Cons:
Obvious delay when updating to new version, including the first launch;
All scripts and styles must be cached in localStorage to prevent browser from reloading these files unexpectedly.
I am sure some of you must have the same problem or idea. I will really appreciate if you share your thoughts here.
If the app is a tool, such as finding nearby restaurants or calling for a delivery service, I believe some pages with fixed layout and styling will do. The functions should rarely be changed, right?
For example, you can have a page showing a Google Map with markers attached to it, indicating all the nearby restaurants. Whenever there are changes to the list of restaurants saved on the server, the client does not require any modifications, as long as the functionality of this page is kept the same as usual.
Think of the homepage of Google. There is always a toolbar at the top, a Google Doodle and a search bar underneath. The layout is almost always the same. What differs is the Doodle which is dynamically loaded. Having a fixed layout should save you from updating your app client too frequently.
By the way, I usually don't update the apps on my mobile phone, as I am too lazy to do so. Therefore, I agree with you that it is better to publish new versions as few as possible.
I created a 1-way sync that updates my local web storage (SQLite) which is on just about every device these days. My sync updates my apps login/users it gets new updates from the db an updates my apps web storage.
You can use regular SQLite to write to your devices web storage that will only update when online.
Recently I submitted an iPhone app that was rejected because it uses the APNS to push messages that could contain marketing and advertising information. Because of this, I now need to create a web app instead of a native phone app.
My problem is that I need to poll the phone’s location in the background. When Safari is in sleep mode I need to somehow have a java script running in the background to monitor location changes. Has anyone been able to do this?
I am developing a Blackberry app using Cordova/PhoneGap. I am fetching several images (map tiles) from a server. Also, every 60 seconds I send position information to it.
However, every now and then either when I fetch the images or send information, I get an error. If I am on a simulator (BB 9930, OS 7.0.0.318), I get an AppError 104: Too many threads message and my app crashes. When I test my app on a device (BB 8520, OS 5.0.0.592) not only does the app crashes, but makes the BB reset.
I have seen other posts with the same issue (like this one, this one or this one). However, I haven't found a solution when building the app using Cordova/PhoneGap (JavaScript).
Thanks!
This may not be related, but I did have a similar problem when doing a lot of request from a native app on a BB Bold. The connection thread was not closed properly after receiving the answer.
try the following:
change GET <-> POST.
change HTTP <-> HTTPS.
if the server is yours, evaluate changing the API to return all the images as one and use an offset/clipping when displaying them. You will save bandwidth and open less connections. your app will load faster.
eg:
http://www.ibloomstudios.com/articles/misunderstood_css_clip/
I doubt if the phoneGap API is causing this as it is basically a layer. Possibly you have an issue with the simulator?
Since you are also testing on Blackberry 8520, It is recommended that you keep the MAX number of threads - running concurrently- at any point of time in your application - less than 12
Since you are using Phonegap, chances are that it may be initiating those threads for your application.
If the device is connected to your system, connect it to Blackberry JDE and see, which threads are active to analyse if you can reschedule your tasks.
Are you using AJAX to get the map tiles and send location to your server?
If you are using AJAX, then you can keep a counter in JavaScript to keep a check on the requests.
Also, have you tried WebWorkers , they would enable you to do all of them within single thread itself.
If all fails, you can also develop your custom Phonegap plugin to do similar things with a Java Script interface API.