I want to send android push notification to the selected user without using gcm or firebase. The application is already built without firebase. Now I need to integrate push notification too.
Question:
How it's possible without firebase?
Actually I want a feature that, when an admin update the value in the one field in database table of particular user, the that user will get a push notification regarding the update. How it is possible?
The way is to create custom Service https://developer.android.com/reference/android/app/Service.html , which is holding connection via socket or polling some remote server with intervals.
But, I suggest that Firebase service is more advanced and optimized in battery consumption and, particularly, in utilizing the sleep mode. It's not trivial to make a service which will have fast response and CPU consumption. I think that a custom service development will lead to native (C++) coding of networking routines libs.
Also, take into account that Firebase provides own Authentication service with ability to seamless convert your anonymous user to registered. There is a lot of pros of Firebase services. And cons are: your users have to install Google Play Services, if your app will grow - you will pay to Firebase.
Look here Android push notification without Google service
It's possible using VAPID authentication.
Google for VAPID and you will find a very tortuous road that could lead to the answer you are looking for.
another option is Gotify. Gotify is self-hosted open source notification solution that you can use it to send push notification to your android app without need of Firebase.
with help of UnifiedPush you can receive push notifications in your android app.
you can easily host Gotify server on Docker and use it's Api or cli,... to send notifications.
here is a good article about Gotify: https://www.linux-magazine.com/Issues/2020/230/Gotify
Related
I am building my first Android app and need to know how I could use push notification.
My project is a home alarm system and also I have built my own local web server. Now I want to push a notification from my server to my Android app when an alarm appears in my server.
Currently my garage doors use the MyQ app and when the garage door opens or closes I get a notification on my phone, I want to implement the same thing in my app.
I've been reading about the Google Firebase Cloud Messaging but it seems exceeding my need.
If you need push notification on your cell phone then you definitely need to integrate your app with Google Firebase. (or at least that's the right way of doing it).
Alternatively, there is something called as local notifications & background process in Android you could do long polling to check if the garage door is open (probably every 2 mins or something). However, I don't recommend that as it can drain your mobile battery.
Also I recommend using Flutter as oppose to using Native Android. As there are some pre-built libraries for android and Google Firebase integration.
Take a look at this Youtube video - https://www.youtube.com/watch?v=2TSm2YGBT1s
Ouh, maybe thats a little bit too much for starting with android - nevertheless I want to help you.
You need a communication protocol between your server and your phone (i.e. Firebase as you mentioned or Websockets).
If your server sends a message to you client (your phone) you have to create a notification. (Android Developer Guide). That's the theoretical part. You will also stumble across a lot of
challenges with
asynchronous programming.
Firebase might actually be the simplest option. You could build your own web socket service too, but that would probably be more than you need. See this previous question for more options: Android push notification without firebase
Android has some services that communicate with firebase to receive notifications.
You'll need to implement a service on top of your web server (using backend languages such as Python, Node.js, PHP,...) so it can send notifications when an event happened (like the door closed) witch isn't a simple way for a beginner.
then your web server sends a message to firebase and tells it to send a notification to my client.
so I highly recommend using firebase because of the simplicity of usage. otherwise, you should implement a separate service on your android phone to get the notification (if you want to run it locally) also as explained do the backend side.
Consider a whatsapp group. When any user texts in group, all the participants receive a notification.
Consider Youtube, whenever a content creator uploads a video, I get notifications.
These are all automated.
How to do this? I use Firebase as backend in my android app.
You need back-end services that you communicate with through an Api from your app. Think of this as a communication layer between Firebase and your app.
Generally this can be considered as a REST API. Here is more reading:
https://restfulapi.net/rest-api-design-tutorial-with-example/
Environment:
Ejabberd Version : 16.04
Smack-android-4.1.0
I have created an Android chat application with a XMPP server. However due to Google play permission issue I had to narrow down the feature from app which supported receiving incoming message notifications when the app is in the background.
As an alternative I received the following suggestion from GooglePlay Review Team.
Once you’ve removed this permission, you might consider using Firebase
Cloud Messaging (FCM) if your app’s message delivery requires a
temporary exemption from battery optimization. Please set high
priority only if the message is time-critical and requires the user’s
immediate interaction, and be aware that setting your messages to high
priority contributes to more battery drain compared to normal priority
messages
So at the moment users can send messags via the app. But when he close the app, he will be considered as an offline user, and will not receive any notifications from app. When he opens the app again, he will get all the offline messages those were saved the Ejabberd server.
I want to enhance the current app so that even though a user had closed the app he will still receive a notification when some one sends a message to him (Similar to whatsapp)
Is there a module in ejabberd which integrates the server with FCM and handles this?
If we can not achieve this by Ejabberd, is there a 3rd party library to support this?
If not do we have to write an Erlang module from scratch?
I found similar questions in the internet but I could not find any working solution. Since I am not much experienced with Erlang and would be glad to hear your solutions/ideas on this. Thanks in advance.
This can be achieved in Ejabberd with offline_message_hook. This hook is trigger when sending a message to the receiver and receiver in an offline state. So create a custom module using this hook and you can send a push notification to FCM and APNs servers.
Refer this blog -- https://jasonrowe.com/2011/12/30/ejabberd-offline-messages/
Looks like you need to try apply approach below:
Create REST API for store of user tokens with JID's of users
Create custom hook for fetch XML packages.
Integrate into project the epns library(this library can send FCM/APNS)
In custom hook call the spawn function where will be get the user token from DB by JID and creating payload with sending FCM/APNS notification
I want to send push notification in my app (Android) using Google Cloud Messaging. I am using firebase for backend. As firebase do not support inbuilt push notification i am using Google App Engine.
I do not have any idea on Google App Engine. Right now i am using a template provided by google for sending push notification.
Google Cloud Messaging Template Github
Till now i have deployed my app in Google App Engine and i am able to send push notification to all devices that are registered (From Web) An HTML page i get when i use GCM template.
What i want to do is , to Listen for Firebase data change and send push notification to user who is not online or has closed the app.
How can i run a servlet in background so that it keeps running in background and send push to user who is not online/connected.
As i have only push notification logic in Google App Engine Should i use servlet or struts.
Thanks in Advance
It is my understanding that Firebase really doesn't work very well with GAE, so you might want to reconsider your choices.
Listening for data changes, as you have mentioned, requires that your app leave a background thread running. To do this on GAE you have to disable automatic scaling which is an important feature of GAE.
You could create a separate backend GAE module with manual scaling and then have it use eg. a queue to notify your main GAE module of a data change, but this seems to me to be unnecessarily complicated and inefficient.
Hopefully Firebase will improve their product so it can notify of data changes in a more efficient and flexible manner, but in the mean-time, perhaps you should use a regular compute engine instance.
I am currently developing an app where users create posts that are stored on a server. When another user shows interest in a post by clicking a button, I want to notify the author of the post using push notifications. I have already set up the data storage using cloud endpoints with Google App Engine. Is there anyway I can use these endpoints to implement push notifications? If not is there another easy way to implement push notifications given my current setup? I have already read about Google Cloud Messaging on the developers page but was somewhat confused. I have kept track of the registration id's but I don't really know where to go from there. Thanks in advance.
You can use the HTTP interface to the GCM servers as described in this
Android developers page.
The easiest way to do it is by downloading the Google Cloud Messaging for Android Library using the Android SDK Manager, which will give you a jar that handles all the complexity of setting up the requests and responses to GCM.
Towards the bottom of that page, there is a sample Java application for push notifications on App Engine which you can use to get familiar with sending push notifications and then adapt to your needs.