Exchange data between android devices of one user without cloud programming - android

i want to program an application that connects different android devices of one user. If happens an event on one device, the other one should be notified (eg. a toast for testing).
Is there a service in the world of google that handles the backend for me, without programming my own server/cloud-app?
An example would be timely from google where i can change the clock on my mobile and seconds later the new value ist available on my tablet.
Thanks

Yes there is a service, that can be used for sending notification to another phone. Here is an official link.
Google Cloud Messaging for Android
And this is an example
Android Device to Device Messaging using GCM via HTTP

Related

Push Notification from local server

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.

A little help in mobile app sector - question

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.

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.

online notification in android

I've built an Android application by android studio.
I want to be associated with users online and notify changes and news.even when my application is closed.
This is what is on my mind,I have web server, i want create a internet connection listener and when connection is available,application or a part of it connect with the server and get new information and notify the user with a notification.even when my application is closed.
How can I implement and enforce it?
Try "Google Cloud Messaging."
Per their Developer Console Help page: "Google Cloud Messaging (GCM) is a free service that helps developers send messages across multiple platforms: Android, iOS, and Chrome. For example, a server can send messages directly to single devices, groups of devices, or devices subscribed to topics. Also, the application on a device can send messages directly to a server and to devices belonging to the same group."
Use the Google Cloud Messaging service alongside the Google Plugin for Eclipse. Google Cloud Platform explains as: "When targeting Android devices, it is easy to get started by using Google Plugin for Eclipse (GPE). GPE allows you to generate an App Engine Connected Android Project that provides the basic logic needed for sending push notifications using Google Cloud Messaging for Android from a mobile backend running on Google App Engine."
This could send messages for you without having to do the work on your own server. If this answer helped you, please consider up-voting or accepting it as the answer. Thanks, and best of luck on your project!
No,These systems are always some limitations and managed with others.I do not need to communicate with iOS or chrome ,I need to design a system that's all for me.Experience has shown me great services, such as Google services and any other company affected by political issues.for example i live in iran right now.
All production-oriented and knowledge-based services for this country is banned.
due to this problems i prefer to have my own messaging and notification system.

Android market initiate remote download

I would like to know how the android market initiates the remote download through their website. I'm guessing there is some sort of push notification system. I want to know if it's possible to do the same thing using a different web interface.
The only possibility I see is to use the C2D (Cloud to Device) messaging API provided by Google. In that way you could send an install intent to the device. However that would always open the market locally on the device from which the user can then install the app.
Obviously Google can bypass these "limitations" :)
They use Android Cloud to Device Messaging (C2DM). They allow anyone with a server of their own to implement this service.
From the site:
Android Cloud to Device Messaging (C2DM) is a service that helps developers send data from servers to their applications on Android devices. The service provides a simple, lightweight mechanism that servers can use to tell mobile applications to contact the server directly, to fetch updated application or user data. The C2DM service handles all aspects of queueing of messages and delivery to the target application running on the target device.

Categories

Resources