A little help in mobile app sector - question - android

I am new in mobile app sector and I think about applications which contains google maps, can be available for Android/iOS (i do not have any experience in Objective-C/Swift, Android), has notifications between devices.
For google maps I did some research and I know that I have to google account for using google maps API. I will be able to display devices on the map in real time. How to find device in some radius?
For notification I know that there is Firebase but I have not used it. I saw it have REST API.
For application I want to use Apache Cordova (I know there is PhoneGap too).
I have backend in Java. I thought about something like this:
Device <-- REST--> JAVA (server/DB) <-- REST--> (Firebase)/(Google Maps API)
Is it possible to send notification device <-> device in my configuration?
Does Firebase need his own DB for user/device etc?
I thought about when someone open the app will see available other devices on map and will be able to "tap" on one of them and send it a notification. Is it possible?
Maybe someone can give some tips/links/knowledge about how i can achieve this or how it supposed to be done.
Thanks

How to find device in some radius?
You tell the server with your backend your location, it responds with a list of devices that are "in some radius" (by executing some code that does whatever you define that to mean).
Is it possible to send notification device <-> device in my configuration?
This is never really possible (or done that way). Notifications always come from servers from Apple or Google. If you want to trigger a notification from device 1 to device 2, device 1 would tell the server about it, then the server would tell the push provider who then tells Apple or Google to send a notification to device 2. (Which of course means that device 1 has to be able to identify device 2 somehow, and that the backend has to know about both of these and have a push token for device 2 saved so that it can tell the push provider to send a push there.)
Does Firebase need his own DB for user/device etc?
Firebase is a platform that offers multiple services. One of those is to send push notifications, another is a database to store information about device or users. So no, it doesn't need "his own DB" but there will have to be a database about users or their devices to be able to send notifications.
I thought about when someone open the app will see available other devices on map and will be able to "tap" on one of them and send it a notification. Is it possible?
That is technically possible, although not in this direct way you described, but what I elaborated above.

Related

create my own push notification service without fcm , pusher ,

I want to create a notification system provider that is not based on Google services or similar. In fact, I want to get information about its overall architecture and needed Android sdk functionality.
The most weird point for me is to understand how to send a notification to an Android device.
I mean, how can I identify the Android device on which my application is installed from millions and millions of other Android devices on the Internet?
And how do I send information to him?
Should I use sockets for this or similar stuff?
simple answer: YOU CAN NOT
before everything else i should correct your question, pusher and FCM are not in the same group at all! you can build somthing like pusher or oneSignal or etc but you can not build something like FCM/APNS
you should understand three simple yet important sentences below:
when you want to pull anything from place_1(e.g. api) to place_2(e.g. browser_client) you most have an identifier of the place_1_resource (which commonly is the uniform-resource-locator of api)
when you want to push anything from place_1(e.g. notification_central_server) to place_2(cellphone_client) you most have an identifier of the place_2_resource
you must know the differences between a real server push with server-push-like technologies like long-pulling or ... and you should be aware that what is intended in this concept is a real server push not any kind of pulling with a push jacket!
if you don't have any identifier for a cellphone which you want to send it a notification, your server dont know where to send that notification so we need a resource_identifier_like for cellphones which is actually a device_token_like and you have just one approach to get this device_token_like and that is the FCM/APNS
FCM is like a dns server containing all identifiers of every android device that google supports (almost every android device) and APNS is just the same but for apple devices
note1: even if your app can obtain it's corresponding device device_token_like it can not be used for push notification if its not registered on FCM/APNS
so when you get that device_token_like identifier of your desired clinet_device now you can use different approaches for sending sth to that clinet_device. there are several approaches like SSE, Webpush, HTTP_server_push, Pushlet and etc but none of these approaches supported by mother_companies of these devices, the only approach that is completely supported and standard is the same approach that FCM/APNS official websites suggests
for example an iranian Incorporation named najva uses webpush to send notifications because of USA sanctions but webPush method works good on browsers and android devices but they didn't even apear on an apple devices
finally i should say that i admire your curiosity to less using anything from a benefit_based Inc. like FCM/APNS in your developing but i strongly recommend these articles and books for you cause i think you didn't learn enough:
wikipedia of push technology
story of some guy who tries to make his own push notification service
Push Technology A Complete Guide - 2020 Edition
Data Push Apps with HTML5 SSE
Short, direct answer
You can't (At least till you create your own ROM)
TL;DR, Reason why?
Before you build your own push notification server, you first need to know how it works internally in android.
Whenever you/your server sends a push notification message to the android client, the SDK processes it and shows you the notification. But when your app is not running (or being killed), your app cannot respond to it since it was not running. In such a case, your notification message is sent to a system service which is known as Google play service. For this even to work, you will first need to bind your app with Google play service and that is what FCM does. FCM SDK registers your app to the operating system service on the first initialization. That FCM service is opened to a port which listened to the incoming message from the server and when it receives the message, it publishes a notification on behalf of your app with a PendingIntent containing the data. Then the PendingIntent is delivered to your app when the user clicks it and then finally your app process the data (or the push message)
So basically, for your server to communicate with the client, It first needs to communicate with the FCM service and for that, FCM gives you a token which identifies the application to register with the internal Google play service.
Simplified furthermore, the workflow is as follows:-
Server send push message ---> FCM ---> Google play service,
If your app is running, it is directly handled by the client SDK So, Google play service --> Your app
If not, then it is delivered by the service itself using PendingIntent So, Google play service --> PendingIntent --->| Publish notification
Totally impossible, Workaround?
There is nothing like impossible because an absolute impossibility doesn't exist. Saying impossible generally means near to impossible. (This is similar to math where also we say tends to infinity because no one has achieved it yet).
To make it work, you need to somehow bind your app to the Google play service and you can't because Google hasn't exposed any direct API to do that. The only possible way is using the FCM ;-) (Bad luck again). So the only possible way is to build your own custom ROM with a custom push service that acts as a client for your Push server and a Server for your Push client (which is your app).
Since the above option tends to impossibility, you have to choose a workaround.
The best among the worst workarounds are:-
To make a malicious SDK.
Malicious because it needs to keep the app running in the background with a service that is connected to a WebSocket endpoint of your server. (Harder in new android versions).
Make use of a database where your push notification is saved and your app checks it periodically using AlarmManager.
Hope you have got the point.

Receive notifications on android upon database change

I have an android app which is capable to interact with a (for now local, but in future online) RESTful database (using PHP and Slim framework).
A registered user can create/upload new text, view all its texts, delete and modify them.
The user can log through different devices (Android smartphones for now, but in future with Desktop computers as well) and perform said operations.
I need that EVERY device (on which the user is logged in) is notified upon each change in the database.
What is the best approach to implement such notification capability either on the PHP/MySQL server and in my android app?
I have heard about Google's Firebase Cloud Messaging but i'm not sure neither if it is the easiest and fastest way to do it, nor if it is compatible with my already working environment.
Please guide me in the right direction as i don't have a clue on what is best for my case.
You have to registered mobile device or desktop to fcm/gcm server or apns in case of iOS . When database is updated on server then it will get a trigger so on after save will send notification push with your payload.

I am using Google Cloud Messaging for push notifications in my app and i have 2 basic doubts about it

Is GCM the only way for push notifications in android? And is it advisable over other methods (if there are any)?
So let's say my app from a device registers on GCM. Is it the app itself which is assosciated with the device that registers itself, or the user and his email id that register? If my user switches devices in future, will the same 'registration token' work for him ? Or in a similar scenario if a user with another g-mail id registers to my app from the same device, do i push notifications to the same device with 2 different registration tokens?
Extending to what i asked in 2, suppose a single user has his g-mail id working on my app on different devices. Does GCM push the notification to all those devices, or only one of them? And if one, then how does it prioritize?
No, there are other push notification services in Android, like Parse. However, it is strongly recommended to use the default push notification service that is present in any Android device that has Google Play Store, because that reduces battery usage. If you are pushing your app somewhere else though, like Amazon Store, keep in mind that Kindle Fire does not comply with this and doesn't have Google Play Services -- at least as far as I know.
The registration token is very volatile and is not bound at all to an email. Actually, sometimes the same device may get a new GCM ID out of the blue. There are many tutorials on GCM's best practices, but Google's is the best way to start. What you should do to prevent problems is store the GCM id of your device in your database, so you can always know which ID is currently associated to your device. GCM may give you new IDs for no reason, so always parse its response properly and store the new ID it may provide, linking it to the device.
GCM doesn't really care which Google account is your app using. That means you can register as many devices as you want with the same account. You have to manage to which devices you push notifications, because the ID is managed by device.
Be careful: there's been some changes with the API lately, so a lot of unnoficial tutorials you find on the internet may point to deprecated methods.
There are other ways of sending notifications, Tokodu and RabbitMQ for example. I wont go over if X is better than Y, since it's not allowed on StackOverflow.
A unique device token is generated for the device, how you use this device token is totally up to you. You can make it unique for the user by, for example, implementing a login system, so that the device token is created and stored in a database (together with the user information). Let's say if two different users uses your application on a shared device, they can both receive notifications on the same device if you allow them to. It depends on your own implementation.
This again depends on how you chose to implement the GCM features on your client and server side. For example, you can choose to store device tokens for each and every device the user has installed the app on, or you can store the latest device token so that notifications are only sent to one of the user's devices.
I hope this helps clear some things up.
Besides good answers above, if you need a push notification solution for a working environment without Internet access, I suggest SignalR of Microsoft, which has already supported Android and Java (you can find out more at GitHub).
Hope this helps little!

Correct way to send push notifications

I want to send a notification from some server to android device. The most obvious(and power-hungry) way is to keep searching some database for any new messages using a service/broadcast receiver.
I am sure there are other ways to get this job done. I took a look at GCM(google cloud messaging) , and it seems that google always keeps some TCP/IP connection active. This essentially means that using GCM will use less power.
However, I have a few questions regarding GCM.
Does a user NEED to have google services, and a registered play id ?
If a user side-loads an apk, will he still be able to receive notifications ?
I would like to know if there are alternatives to GCM
What about devices running forked android versions, like nokia X , kindle etc? How are push notifications sent to those devices ?
Does a user NEED to have google services, and a registered play id ?
Yes, it is necessary to use Google Play Services in your development. However users do not need to have a Google account or the Google Play Services Installed.
If a user side-loads an apk, will he still be able to receive notifications ?
Yes.
The steps that must be followed to send a notification to a device are:
Developer creates application in Google Developer Console
User installs application
Application gets a NotificationID and sends it to your database
You store the NotificationID at your servers with any other information related (your username, device info, etc.)
Whenever you want to send a Notification you connect to GCM sending one or more NotificationID and the notification content.
The users related to the NotificationID will receive in your Application the notification content.
Do any action you need.
Have a look here.
IMHO there is not any real alternative to GCM in Android (based on efficiency and simplicity). You may look for 3rd party services that will help you in the implementation and add value (marketing, business intelligence). As an example of this take a look to UrbanShip.
If you want to implement your own solution you should have a look to WebSockets. This will mantain an active communication between your server and the device. Those sockets are thought for real time communication between your server and the mobile.
Two issues:
How is the application affecting the battery depends on your implementation and the application use-case (how frecuent are you sending information, how long is the connection stablished).
I am not aware of any native implementation of this in Android but there are a few Libraries coming from open source projects. Google it.

Syncing Data between multiple android devices with 1 google account

Good day,
I really hope someone can help me with this.
I'm having difficulties trying to sync data between 2 devices. Google Cloud messaging seems like the thing I want to use, and I've played with the tutorial. However I had the following questions:
I'm broadcasting commands to all users.. How do I send messages to a specific user?
How do I send data back to the webserver?
Is this the correct way of syncing data between multiple devices using the same google account?
The data will really be a small amount, so I do not need a massive server to accomplish it, and the 4KB limit on GCM will be more than enough.
PS I'm using Android studio.
Thanks for the help
I'm broadcasting commands to all users.. How do I send messages to a specific user?
Each device has specific registration ID. You can specify a particular registration ID and ask Google to send the Push. See Server example for that.
How do I send data back to the webserver?
If you want to send the data from device to your 3rd party server, you can either send it via HTTP or you can use device-to-cloud feature of GCM Cloud Connection Server.
Is this the correct way of syncing data between multiple devices using the same Google account?
I think the way you are going, you can accomplish what you want. I'm not aware of better alternatives though. Also, How to sync data between different devices might help.

Categories

Resources