Polling, Pushing or Something Else?

My iOS app is just another client for a subset of my company’s web services - it calls web services to download data, “caches” that data in a SQLite database and periodically, or on user request, updates that data with repeated calls to the web services.

It would create a better user experience if the app could be notified of a data change by the services so that it can instantly update the local cache and display the changed data. I understand some apps do this by opening a web socket connection, or else use something like Apple Push Notifications. Our services architect is keen to use HTML5 Server-Sent Events for this.

I was wondering whether anyone in this forum had considered this issue for their own app and had arrived at a solution?

Well, remote push notifications are currently not possible in Xojo because the entitlements file is not respected when an app is built. See <https://xojo.com/issue/38187>

[quote=169114:@Jason Tait]My iOS app is just another client for a subset of my company’s web services - it calls web services to download data, “caches” that data in a SQLite database and periodically, or on user request, updates that data with repeated calls to the web services.

It would create a better user experience if the app could be notified of a data change by the services so that it can instantly update the local cache and display the changed data. I understand some apps do this by opening a web socket connection, or else use something like Apple Push Notifications. Our services architect is keen to use HTML5 Server-Sent Events for this.

I was wondering whether anyone in this forum had considered this issue for their own app and had arrived at a solution?[/quote]

There is no WebSocket or HTTPServerSocket. I looked into creating an HTTPServerSocket and finally gave up.

For the time being, I see no other way than polling with http.

In the “creative bag of tricks” category. HTMLViewer does receive push. I wonder if it were not possible to connect an HTMLViewer to a web app and detect changes through JavaScript. If it were possible to get the URL of the viewer through a declare, we could use the same technique as with desktop HTMLViewer and change the hashtag to pass values back to Xojo. For instance, I imagine a page with a single label which the app updates when data is available. It is pretty simple to have a JavaScript detect the change and report to the app. Then you pull the data.

I know a guy who has an Objective-C app that makes heavy use of his own web services and he’s warned me off Apple Push Notifications, saying that they are really only for notifying the app of infrequent events and not for sync. He uses a service called PubNub (link text which he describes as “awesome”. But of course there’s no Xojo code for it…

Sounds like for what you want there may be several ways to do this
Things like message brokers - which often also have a store & forward capability so messages dont get missed even if the client is offline
ApacheMQ and a pile of others are available

Unless you REALLY need the real time throughput
Theres even an old article in Xdev about this sort of thing
http://www.xdevmag.com/browse/6.3/6310/
https://stomp.github.io/implementations.html

and somewhere around here I still have code for it

Hi, I am a fan of Pubnub and use it in some of my native iOS apps. I have a need to write a server side app and my goto was normally PHP. But I have also been a RB (now Xojo) fan for eons and I would like to now explore what is possible. Just started reading about a webSDK wrapper, my javascript knowledge is not the best, but here is my question.

Refer to: https://cdn.pubnub.com/pubnub-3.7.15.js
Info: https://www.pubnub.com/docs/web-javascript/pubnub-javascript-sdk

Question: Can I access a js file like the above - create an instance, call its functions and listen to the callbacks? Do I need to have a GUI for this i.e can I do this in a console app?

If so, how hard is this to achieve? All the reading I have done so far has not helped me to date so a pointer to some examples would be much appreciated.