I'm developing a Transport Management System using Dingo API with Laravel and Retrofit for Mobile App. When the clerk approves the request, the notification should be send to who uses android app(Client),So i wanna send data from Server to App.What are the possible ways to do it ?
Updated
How to use brozot/laravel-firebase cloud messaging ? Can anyone give an example for that ?
We can use:
Use push notification system like.
This approach is supported by Google. But is delayed to inform like what you are doing is right. Work that is not suitable for real-time. And does not require you to have a server and a lot of code to write.
https://firebase.google.com/docs/cloud-messaging/android/client
Or
https://developers.google.com/cloud-messaging/ -> move to firebase upper link
Use signalR
This real-time but connections are not loose management.And a lot of coding.
https://github.com/ahmadaghazadeh/SignalRAndroid
Related
I want to develop a website that will be able to send push notifications to a mobile application that would be able to run on both android and iOS.
For the last couple of years, I am working as a web developer so developing the website is not something that I am worried about, but I have never developed a mobile application before, the mobile app would only receive notifications from the website so the main functionality would be in the website.
Can anyone suggest me what the best approach is and what I have to learn to be able to do this?
Thank you in Regards
I guess, you have 2 options.
You can either use Firebase FCM
https://firebase.google.com/docs/cloud-messaging/
or use a third party which is called OneSignal
https://onesignal.com/.
If you are looking for an easier way then I recommend using OneSignal instead. You just need to define API Key in your build.gradle and initialize OneSignal in onCreate().
The best approach, in my opinion, would be to use firebase (https://firebase.google.com/products/cloud-messaging/). I think it is better because it is a unique framework for both ios and android and you don't need to worry about the user device when sending the message(you could build an interface in your backend code to handle this but why doing something that already exists and it is free).
The flow is something like this:
on the first start the app(either ios or android) must send its firebase ID to your server so that you can store it (simple http request will od it) and set up a listener for the incoming push messages
when you need to send a push message all you need to do is an http request and you can trigger it with js from your website. The request will contain data such as the firebase id of the receiving device(which you have previously stored)
Firebase Cloud Messaging also have some really nice features like upstream messages(push messages from the device to the server, but you need an xmpp server to listen for them) and topics to send the same notification to many users at the same time
I think the best approach would be to create a node server where the website would be running on and then use Firebase Cloud Messaging (FCM) to send notifications
EDIT: FCM supports both Android and iOS
I want to send a notification to the device when some condition satisfies on the data returned by API call on the cloud. I can easily do this on the device but using API every minute, for hours, might drain the battery and use a lot of internet. API returns JSON data. I have never used Firebase before but have used others (like Kumolos). Is there a way to do this or do I need to write code on the device?
I am coding for android.
You have to implement it on server side. For example you can use cron-job with PHP technology and window service or SignalR for .Net technology. For SignalR client side library is also available for android and ios
I am currently writing an Android app, and I would like to send push notifications from my server to the phones where this App will be running. Due to security reasons, I would like to avoid any third party server like Google's servers that are used when using GCM (Google Cloud Messaging). How can I achieve that? Or do I need to use a workaround (e.g. polling or working with GCM and encrypting the messages)?
Thank you very much in advance for your help!
The easiest way to prevent Google from reading your messages is simply not sending any data to GCM. Use send-to-sync-messages for that. To improve performance use collapse_key.
On receipt of a send-to-sync-message fetch the new data from your webservice. I also used this approach in a recent project with high security requirements.
Is that possible to make an android app await for incoming requests. Maybe my terminology is bad, but I need something like a server on android. Instead of sending requests to the server on and on to check if a status on the server changed, I want the server to send this information directly to my android app. I heard it's possible, but couldn't google it, maybe I used bad phrases...
Any help appreciated
A Google advised way to do it is use Google Cloud Messaging for Android:
Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users' Android-powered device.
Try to look to Push / Pull notification.
Related SO thread
How can I send data from a server to an Android device without the device polling for data?
This is called a server side 'push' and is commonly referred to as 'pushing'. This is a well known feature of the iPhone, however, it does not currently exist on the Android. Android Cloud 2 Device messaging has not yet been released to the general development community. you may want to check out projects such as MQTT and Deacon.
You might consider using Googles cloud to device messaging for a solution.
You'll have to sign up for an account and are only able to use AppEngine servers at the moment.
Your application has to use API level 8 (2.2) in order to be able to receive the cloud's pushes.
GCM (Google Cloud Messaging) is the easiest way, and while GCM provides the basic service of sending messages, there are companies out there that do help you get up and running.
You could take a look at companies like urban airship, xtify and mBlox (developer.mblox.com) to get started with this and have a few additional tools that help you structure the push notifications in a more structured way.
Good Luck with your development!