i need to make an app on android wear that when a button is clicked, a message is sent to mobile. If i made an app that is listening on mobile, then all found 100%. But if i close the app on mobile the message cannot be received. How can i make a service in background that listen for message sent from my wear app?
You need to use a WearableListenerService in your mobile app; once you register such service in your mobile app and its manifest, then messages can be routed to that service even if your app is not running.
Related
I must push notification from my own socket side server when the application is closed or application is in the background. Where do I need to write a typescript code in my project to solve this problem?
The push notifications require registration between your mobile device (the app) and the Push Notification services (Google GCM/FCM or Apple APNS).
Registering your application via a unique identifier will allow your application to receive notifications (actually the OS will handle them) anytime, even if the application is closed, in background or foreground.
If you want to send data (represented as notifications) from your server via sockets you should consider implementing a background handler to listen for that data. If the app is closed, you may need to use a Plugin (native code required) to wake up your app and listen for changes.
Have a look here to understand better how the Ionic Apps are working in background with Sockets.
How does the Facebook messenger establish video calls when app is in background?
I'm making an android video call hybrid app using webrtc and socket.io, the video calls works fine with app open but I don't know the best way to contact a target user if he's not in the app, my idea is to send a push notification to wake up mobile and enter in the app and then start the video call, the problem is if target user don't allow notifications.
I've already tested calls in messenger with notifications disabled and with the app in background and the call works the same. I can't find any explanation how messenger can start a call when the device is not awake.
Is a notification or a service that allows that?
Check out Firebase Cloud Messaging, it's what most people and what Google recommends to use to push notifications. However, that doesn't mean it has to be used to send notifications and it won't be blocked even if notification is disabled. You are able to send data payloads with FCM and handle them on your client with onMessageReceived with FirebaseMessagingService. For more details, refer to the documentation.
I'd like to ask a question about how Android app behaves after the OS has been restarted.
I have a messaging app which needs to listen to SMS messages (using the method in this post)
Assuming that the app is supporting Direct Book (Android 7.0 and above), the app will receive the SMS messages when the user unlocks the phone but without having the user to open the app. Is this understanding correct?
And, assume that the app is not or cannot support Direct Book (before Android 7.0), can the app receive SMS messages when the user unlocks the phone, without having the open the app?
Thanks!
it sure can
register your BroadCastListener to a Service detached from any activity's lifeCycle and do your business there in the service's class
and register another BroadCastlistener to start that service when the phone is booted
I am trying to implement an Android chat application using web-socket.
I am using an Android service to connect to the web socket server. It is working fine, but when I force stop the service (Not the application) manually in task manager
(Settings -> Apps -> Running)
Then my application is not receiving any messages from server. What I observe from other chat applications is even if I stop the background services of those applications, they are receiving messages and after some time the services also automatically started. How is it possible? Is there any other hidden service that wakes up the main application thread?
You can force start the service every time it is force stopped
Take a look at this (How to automatically restart a service even if user force close it?)
Most of those apps are using a push service such as Google Cloud Messaging.
Continually polling servers or maintaining a persistent web socket is not a resource-friendly method of receiving messages from a server over an extended period of time.
To my knowledge, they do not have a special way of doing this. They may have "work arounds" that are convenient (for example, Facebook Messenger can wake the FB app, if you have both installed and stop only 1 of them).
As of Android 3.1, an app cannot wake itself and GCM also will not wake it. See here: GCM push notifications on android 3.1 : disable broadcast receiver
CommonsWare usually knows what he's talking about. Also, I have tested it and it doesn't work for me on the 3.1+ APIs.
When none of the activity is launched even once,i want to send a push notification to the user.
For example, once user installs application but doesnt open then a notification is pushed that please use the application.
Please help me with the code.
You can't. How would the user call the registration process for the push messages if he never ran the app itself? Until he does, the app is considered to be in a stopped state and you can't interact with it unless you have another app installed that would "start" it.
You can start a background service on application level and registering on gcm server and other process so even if app is not used you can send notification as your service has registered your device with gcm id on your server.Call api for registering device to your server from your GCMIntentService class.