how to use socket.io with background service on android? - java

I use gottox/socket.io-java-client on android chat app.And Now I want to use socket.io as a background service.In chat app If a new message (when chat app is closed),send a notification like "new message on chat app-click here if you want to see.
How can I do that? I did a chat app with node.js,gottox on android.But I need this app work as a background service on phone.Do you have any plugins or examples?

A service or any other Android component can be closed by the operating system. The solution is to use Android notifications to wake up any component.

Related

Is there any possibility of general notification for an android-based WebView mobile application?

Is there any possibility of general notification for an android-based Webview mobile application?
Hi there. I have built an android based WebView mobile application of Nextcloud. [Nextcloud is a suite of client-server software for creating and using file hosting services. It is enterprise-ready with comprehensive support options. Being free and open-source software, anyone is allowed to install and operate it on their own private server devices.] So the activities in nextcloud will be notified with in the website without any issue.
We wan't the notfication to pop-up, like general Android mobile applications. Can any one help me. First i need an clarification is this possible or not?
While using Chrome, The notifications of any websites will be pop-up in our laptop. Like wise we want the webview to pop-up the notifications in mobile.
As far as I know, your requirement is not possible directly. The web push notification only works for the browser. In that browser will be responsible for showing notifications for the user. For example, let us consider we send web push notifications with FCM. Notification will be sent to Chrome/Mozilla server from firebase and it will be delivering it to devices. The browser is responsible for push notification permission handling.
First, webview cannot handle permission.Webview does not have a push server. So it can not receive the notification sent from FCM server.
Alternatively, you can try with service worker api in webview and handle receiving notifications natively. Web push internally uses manifest.json(To configure notification icon,name,fcm id) and service worker API to achieve push notifications for web apps.
Else you can use try Trusted Web Activity(TWA). It uses Chrome custom
tabs to load the webpage. It required Chrome in the device. Since Chrome custom tabs runs on top of chrome, it can handle push notification delivery.
But not sure whether the notification will be delivered via chrome or the app. If your app is a PWA and it uses TWA, a notification might get delivered to your app. Otherwise, it might get delivered through the Chrome browser

Send notification when app is not running

First of all I don't know what type of code to put for my problem.
I'm developing an Android mobile game, with two ways to earn ruby, via mini transactions or via the OfferWall IronSource.
Regarding the OfferWall, those are tasks to complete to then receive Ruby in exchange.
Now my problem that I would very much like to solve
When a user completes a task and the app is not running, how can I send a notification?
zigg, my suggestion would be to call firebase notification while running background service or you can use push notification as Blundell suggested in background service.
The background service will run even if the app is not running. I use foreground services and call push notification in the service when the app is closed or in background.
Hope this helps.

Android Studio - Insistent Notifications on Oreo w/ Notification Channels

I am currently developing an app where insistent notifications are required. However, I can't seem to get them to work unless the app is open. Is there a way to get insistent notifications connected to the notification channel, even when the app is not open? I'm using a Windows Service to curl the notifications. I'm developing on Oreo. Thank you!

Sending message from Android host device to wear when app is not running

I'm building a simple motivational quote app that generates a random quote from a MySQL database. The app works fine on mobile and I want to sync the quote message to a Wear device. I'm using MessageApi to do so and used this tutorial to set it up: http://android-wear-docs.readthedocs.org/en/latest/sync.html.
However, the message functionality only works when the app is running on the host device. I need to launch the app on Wear alone and still be able to receive the message from the mobile device. I thought of running the same application on the Wear device where it will run an httpconnection on it's own but from what I understand this is not possible with Android Wear.
So my question is, is there a way to open an app on a Wear device that will trigger the mobile app to open in the background and hence receive the message that way?
Your mobile app can implement WearableListenerService. In that service implementation, you can listen to messages that are sent to your phone from your companion app on a wear device (when such message is sent to your phone, the framework on your phone starts up your service and passes the message to it). You can then implement the logic you need in that service (fetch a quote, etc) and respond back to your wear's message; when its work is done, that service will go away on its own. For this to work, your wear app needs to send such message to your phone app upon start up (or whenever you see appropriate in your app). This approach should work and probably is the most appropriate approach for your use case.

How to implement Beluga or WhatsApp like messaging system in Android 2.1

I am trying to develop a message app within my android app. The message will be like whatsapp and beluga. I googled it and found C2DM Android 2.2 can send the push notifications to the device. However, this is not available on Android 2.1. Anyone knows how whatsapp send the notifications for 2.1 devices?
For Android: Whatsapp is build upon C2DM and when the app opens it opens an XMPP connection to their service to deliver the messages instantly. They also might use MQTT as a protocol to minimize battery usage. That's basically it.
Edit: I learned more, Facebook uses MQTT in their messaging app. Whatsapp is build upon XMPP with their own extensions. Their server side runs on top of ejabbard (XMPP implementation in erlang). http://www.ejabberd.im/
On pre 2.1 devices WhatsApp probably keeps a connection open to their XMPP servers in the background but this is not really good for battery life.
C2DM is replaced by GCM (google cloud messaging) now . you can use it for delivering the notifications to your app . For the exchange of message one should rely on protocols like xmpp (whatsapp), mqtt(facebook messenger), mtproto (telegram) etc.
if you are looking to familiarize yourself with GCM . try out this tutorial by appsrox - Create an Instant Messaging app using Google Cloud Messaging (GCM)
they are using GCM for the message delivery as well. it won't suit for production, but its an excellent resource for people who want to develop an instant messaging android app .
I don't know what exact technology is used in whatsapp. However, if i am to implement notifications where there is no support for push notifications from the OS, i can do two things:
Poll a remote server every X seconds and check for new notifications (this is the more expensive choice).
Run a background service, maintain a connection with a remote server, which will pump me any notifications that are to be received (sort of my like my own push notification implementation).

Categories

Resources