I'm building a nextjs app with a dashboard having multiple screens. I'm thinking about using setInterval + HTTP versus Websockets to update the ui after the changes in the DB.
My reasoning is that Websockets can be a bottleneck for performance at scale, but at the same time, setInterval may not work predictably when the window is minimized or the user switches tabs.
What will be your suggestion on this matter?
Related
I coded a Chatting App and a Alarm clock App in React Js and they're working fine in foreground (while the apps are opened on screen). But I need a way to keep them running in the background to check for latest messages or to play the alarm sound. (Like clock app in phone or WhatsApp/Facebook)
Does anyone has solution?
I can't seem to find any solution, either by myself or Internet.
If you are targeting mobile devices, the best solution you have is to run a service worker, which can execute code in the background and show notifications. There are limits to the APIs available to a service worker, so playing a sound might not be possible.
I have a Node.Js app running on a publicly accessible server.
I want to make it possible for users to access it as a native iOS app.
Is there a simple way of simply making an iOS app and having it show my Node.Js app running from the server? Or it's more complicated than that?
I looked into PhoneGap but maybe some other recommendations also?
Thanks!
PS I know the question is broad but that's why I'm asking – to focus my question and to know what to do next.
Node.js - this is a server side application. So you need to build client application which can communicate with your node.js server by Rest api or so...
As you mentioned you can build hybrid html5/js app with PhoneGap, Cordova, Ionic "wrappers/libraries" which will pack it into native iOS/Android/... application and that app can talk to your node.js server and transfer data you need.
Also, as Daniel Larsson mentioned for some specific pages you can use webview to display page straight from the web, but webview can be a part of your application but not an entire application, because Apple will reject it during review process.
If you want to port your existing web-app over to being a native app on the app store, I can positively recommend PhoneGap having developed multiple apps with it after completing the same research you are doing now.
As NYS said, you'll need to package all your web-app design (HTML/CSS+images/JS) inside the PhoneGap app, any other way simply wouldn't be responsive enough.
As for what to do next, I would dive straight into creating a PhoneGap application and see how your app runs inside the Cordova wrapper out of the box. The issues I faced were with scrolling on divs holding content, and non-responsive click events, both were easily solved with javascript libraries.
Cheers Chris!
You may use Socket.io for native option.
http://socket.io/blog/socket-io-on-ios/
https://github.com/socketio/socket.io-client-swift/
https://github.com/pkyeck/socket.IO-objc/
https://github.com/square/SocketRocket/
I was thinking about how to architect my project. Im making a meteor webapplication for the normal browser, which will be a 'eventmanager'. which will be used to make events, that a seperate meteor app will then connect to via ddp, signup for the events etc.
So im obviously using DDP to connect the two apps but suddenly i was wondering where meteor places the serverside code in a mobile application, since this is a huge deal, a mobileapp has to work even when not on the internet, so i thouth that it would be logical that some of the serverside rendering was happening offline on the phone, and if thats not the case, well then i would have to seperate my app somehow, into something that renders with the localstorage data if not connected to the internet & i would have to sync the two applications databases + local storage.
Im thinking that the serverside code does run on the mobile phone, it just feels counterintuitive that each mobile phone has its own 'server'.
thanks for any help :)
Cordova is just a wrapper. It works just like any other browser. While it does provide API access to the hardware, the app itself is not native. It's a hybrid app platform.
The client side runs within the app container (Cordova) and communicates with the server portion over sockets.
I am developping an app for Ipad (2 and 3).
The app needs a continuous synchronization with a remote web app. Point is, my app needs to keep "listening" whenever there is connectivity in order to receive updates (lots of data), alerts,... etc.
PS: Before going further I would like to highlight that my app is not targeted to the appstore and moreover it can't rely on push notifications.
What I am confused about is the multitasking on the ipad. I would like my app's local db to stay synchronized by communicating with the remote web app. And hence my questions are:
Does any of the ipads have a real multitasking? (like android's where you can have "services") Meaning that my app or at least a small part of it would still operate even if it is not active on the screen.
How can I achieve that using phonegap standard framework?
If the above points show that at some extent it's not possible. Is there still a possibility to extend phonegap with a plugin and make this happen?
If the above three points are unfortunately fully negative; how would you address the problem by keeping in mind that the syncrhonization involves a lot of data and is mandatory to cover the app's usability?
Does any of the ipads have a real multitasking? (like android's where
you can have "services") Meaning that my app or at least a small part
of it would still operate even if it is not active on the screen.
IOS only has limited background services - in that your app goes into a background state when not active. Really only limited to receiving push notifications. As Phonegap uses a webview and javascript that is only active when the app is active in the foreground.
How can I achieve that using phonegap standard framework?
If you want to keep data connection open you might have to look at development of an application for a computer tablet, rather then an IOS device.
If the above points show that at some extent it's not possible. Is
there still a possibility to extend phonegap with a plugin and make
this happen?
No.
If the above three points are unfortunately fully negative; how would
you address the problem by keeping in mind that the syncrhonization
involves a lot of data and is mandatory to cover the app's usability?
You only option (if you can only use phonegap) is to have the app active all the time, and set a constant sync using Jquery & XML/JSON data. Of course this depends on what type of data you are going to show. For showing a page of data - similar to a webpage you won't have any problems - as long as you understand once you change apps that data won't be synced.
I would like my app's local db to stay synchronized by communicating with the remote web app.
If I were you, I'd be questioning why would I need to do that? Why not just make the app works online? You can have all the assets locally, and just setup some sort of API to retrieve whatever data you need to display on demand.
Otherwise, you'll need to hack your way through to do all the things you wanted, plus you need offline / online syncing. Since you have most data available offline, I assume the app also works offline? And you'll have a really bad time working on offline / online syncing...
I am working on a site for mobile devices. The site is available through normal web browsers and also through an app which is just a browser shell and brings up the mobile site. In our efforts to speed up the loading of the site in mobile we have reduced requsts, made use of data uris, etc. Recently we have started using localStorage to save styles and JavaScript data to the device.
Why you may ask?
In our testing, mobile browsers maintain their cache throughout their session and when the browser is closed and re-opened. The app maintains its cache as long as it is being used, but when it is closed and re-opened it re-requests everything, thus slowing down that initial load.
The problem is, we have styles and JavaScript that are specific for if you are in the browser or in the app for a few small things. We've seen a few things break around these subtle differences and my best theory is that localStorage is shared between the browser and the app. And a user that uses both the site and the app may have problems if the localStorage was set by one and needs something else for the other.
I can't find any documentation that confirms this theory or not, and short of creating an app just to test this I figured I'd ask if anyone has any ideas?
If you trust Apple...
Like cookies, storage objects are a shared resource common to web
content served from the same domain. All pages from the same domain
share the same local storage object. Frames and inline frames whose
contents are from the same origin also share the same session storage
object because they descend from the same window.
Because the storage resource is shared, scripts running in multiple
page contexts can potentially modify the data stored in a storage
object that is actively being scrutinized or modified by a script
running on a different page. If your scripts do not notice these
changes, you may not get the results you expect.
If you are populating your app with data from the same place as the web app, I would suspect there are some keys being modified by the other one. I know that using sessionStorage.clear() will wipe out keys if the web app and offline app load data from the same domain.
As Chiguireitor said it depends on what mobile OS the user is using, but in my experience iOS 4 & 5 share the same localStorage whether you're accessing the mobile app through the Safari browser or as a homescreen web app. And of course if you package it with something like Phonegap it acts as its own app therefore its localStorage is not shared.