Using GAE channels without browser - google-app-engine

I want to write GAE based application that synchronizes information between computers/phones. Right now I am only querying periodically, which causes delays or requires user to click a button to refresh manually.
With GAE channels, it should be possible to do it this way that a device can be notified when it should refresh. However, since I want it to be a desktop app (not web app), I am wondering if I can write my own client to channel API? Or grab whatever's out there.
Is the protocol documented or are there clients available for anything other than JS?

The only official interface is the Javascript client library. Although you could reverse-engineer how it works, since it's not a documented part of the interface, it could change at any time without notice.
If you're interfacing with Android phones or iPhones, each of them has a 'push' messaging API that you could use (Cloud to Device Messaging for Android, and Push Messaging for iPhone).

There is now a Java implementation for the Channels API. It was just released days ago and is available via git at https://github.com/gvsumasl/jacc. I've also taken the liberty of forking it and providing a mavenized version at https://github.com/hatboyzero/jacc.

Related

listen to Firestore's onSnapshot while app is not running

I want my app to be able to listen to onSnapshot while it is in background , I know that I can use background task for this by I don't know how to set it up .
btw I'm trying to implment this so that my app can push a notification whenever a new doc is received while app is in the background .
Most mobile operating systems severely limit what the app can do while it is backgrounded. Keeping an active connection open to a server is one of those things that has never been allowed on iOS, and has gotten more restrictive with recent Android versions.
The better approach is to run the code that detects a relevant change on a server, and then use Firebase Cloud Messaging (or APNS directly if you're only targeting iOS) to send a notification to the user. When they they tap on that notification, your app is started and you can load the data from Firestore.
If you don't want to run your own server, Cloud Functions is a common alternative for this, as it has built in triggers that respond to changes in Firestore. For an example of this exact scenario, see the documentation on notify users when something interesting happens.

How can I get codenameone client to work with a server supporting EventSource

I am working with codenameone and trying to build a client to connect to a server that is using the Eventsource API to send real time updates. I have the javascript sdk but would rather use something more native to codenameone. IS there any such thing? Or does Codenameone ConnectionRequest support EventSource?
At this time we don't have builtin support EventSource mostly because there is not that much demand for it. The only Java client side library for this I could find was this one: https://github.com/aslakhellesoy/eventsource-java/blob/master/src/main/java/com/github/eventsource/client/impl/netty/EventSourceChannelHandler.java
Which is problematic as we don't support those specific API's (netty).
Most developers who need low level event based communications are using WebSockets which we support well through https://github.com/shannah/cn1-websockets/
You can also use direct TCP streams etc.
In a native app you would normally use push notification to trigger an update from the server. This works well for apps that aren't running. You can learn more about our push notification support here.

Disabling mobile web browser notifications when native app is installed

I'm at the beginning of spec'ing out a project to implement browser notifications. From a high level it appears like it will be something similar to:
Create a service worker which subscribes to a pubsub topic.
Leverage the Notifications API and WindowClient to publish a browser notification when an event happens and the window is in a non-foreground state.
Seems, straightforward enough. However, I'm getting a bit hung up from a mobile perspective. Namely, it seems to be the typical pattern that if a mobile device has both the mobile website open and an application installed, the native notification should take precedence and the browser notification should be silenced.
However, I can't seem to figure out how a service worker would inspect for the presence of a mobile application. It is entirely possible that I'm approaching this problem from the wrong perspective though, and the typical recipe for this is handled differently.
Brent, IIUC your question is a non-issue because topic-based subscription is simply not supported by either the W3C Push API or the IETF webpush protocol. I'm afraid that this is by design :-(
Therefore your native app will not be delivered the same broadcast message as your browser UA.
If OTOH you were talking about save-to-homescreen WebApp and a web-page running in a tab then, I believe, your service worker can choose which member of the active client collection to foreground (if necessary) but there will only be one toast message (if at all given rules governing blind/invisible notifications)

Best/Correct way to create a client-server constant listener

I am creating an app that involves sending and receiving settings... The desktop application is constantly sending information to a hosted MySQL database, and the Android app will query this same information. It is something similar to the whatsapp web (but in this case, I'll be using a desktop app instead of webpages).
Until this part, everything is working as I need... but, this same Android app will be used to send settings to the desktop app, and the desktop will read and change its settings according to what was just sent.
If I need to constantly query the hosted MySQL database and check if there is any kind of changes sent from the Android, I believe that I'll have a performance drop... each time a query loop is finished, I would have to query, check for any modifications and so on.
Is there a better or correct way to do this kind integration between two apps? I've read something about WebSockets, but I don't have much technical information about this, neither examples that I can use in this case.
Thank you very much for your knowledge sharing.
Here are some useful sites on WebSocket:
http://websocket.org
http://blog.kaazing.com/ [some useful blog posts]
http://www.html5rocks.com/en/tutorials/websockets/basics/
https://goo.gl/5OaJff [mozilla site]
You may want to consider the Observer/Observables pattern. The MYSQL is the Observable and your desktop app and Android app are Observers (and you can add other Observers in the future). Its a common pattern with lots of examples out there. But you'll need a centralized WebSocket server and an Observer/Observable coordination subsystem. You can setup a pub/sub message broker that uses WebSocket with a nice JMS, MQTT, etc, API to make your life easier. ActiveMQ, IBM MQ Lite, Kaazing JMS Edition... lots of options.
full disclosure. I work for Kaazing.

Does codenameone support activity detection which uses CMMotionActivity (IOS) and Google Play Services ActivityRecognition API (android)?

Being a Java developer, i am super excited to use codenameone for an app that I am planning to write from scratch. But would like to know if codenameone supports activity detection which uses CMMotionActivity in case of ios or Google Play Services ActivityRecognition API in case of android ?
Particularly, my app would like to receive events when the user is stationary, walking, running, cycling, driving/automotive etc. Also, if i can fine tune the battery usage settings in case of location services subscription as provided by Google play services location apis, that would be great.
I hope i wont get disappointed. I was planning to learn codenameone and use it in my app only if these above features are available
I'm afraid they aren't available out of the box. However, Codename One is very flexible and you can use native interfaces to expose these features by invoking native code.

Resources