I wanted to know how to address a specific android phone to send push notifications as the google's gcm is slow and also as i want to learn how to send push notifications without google cloud messaging and to build my own api for sending push notifications to other platform devices .
I'm not sure how to address an android phone whether by its IP address or keep a socket for listening at a port.
Please help!
You not need to use ports or some listening mechanism to build. Use the Google's GCM way.
You need to build a service that will periodically check your server for any massages to get (fetch) for your specific device (keep a self created unique id with each device and registered the device on your the server by that id). Actually this is not pushing. but this is what happening in the GCM server also. When you put some massage for some specific device to your server(it is the pushing) the device will grab that by the service running on it.
simply you have to create a server by yourself (like GCM server)
Then you have to create a service to run on mobile to check updates on your server (like android play service)
Related
I am trying to figure out how Firebase connect to specific devices and send message to it. I now how to use Firebase and send notification to registed devices from my backend server but i don't know how is it working internally. Is firebase severs using persisted connection between device and server? What kind of tehnology is it using?
For now i am mostly interested in Android devices and how firebase wake up device even with background tasks restrictions.
FCM is able to wake a device because the message is actually received by software components that come with Play services, which operates with elevated privileges. Play services can choose to wake the device and deliver the message to the target app.
The FCM software in Play services keeps a persistent socket connection open to its backend under normal circumstances. If it gets connection is dropped, it has logic to reestablish the connection without taxing the battery too much.
I tried to explain how GCM works in my answer here. The internal working principle of Firebase is similar in my opinion.
When you are installing an application which has the Firebase SDK set up in it, it gets a push registration ID from Google server. Usually, you save the push registration ID in your server as well. Hence, when there is a situation for sending a push notification, your server uses this push registration ID to generate a request to the Firebase server for sending a push notification to your device.
Now let us think of the receiver part as well (i.e. your device). In my opinion, in newer versions of Android allows a JobScheduler to check repeatedly for push messages from the Firebase server and if there is one, the device notifies the corresponding application and the application then generates the push notification.
Hope that helps!
When I receive a notification on my phone, how was the push server able to communicate with the device?
Is there a constant connection between client and server? As far as I know something like WebSockets will put a huge load on the server side with all these devices.
Is it some kind of polling mechanism by the client? Seems still like a huge load of requests.
Does the client keep the server up to date with his IP address? How comes no firewall blocks this request (like the one of the router when using Wifi)?
Thanks!
Push notification for iOS and Android are services from Apple (APN) and Google (Cloud Messaging) respectively. For example for APN, the server sends the message to Apple's APN server, including a token that identifies the device. In fact the token is unique for your app running on a device. Obviously the channel is secure and your server need credentials (certificate).
I've added push notification to my ionic mobile app using this tutorial : https://devdactic.com/ionic-push-notifications-guide/ and it's working fine.
The problem now is, to send notifications you need a device token from the phone (this is obtained after registering the device) and the server api is going to use it to send the notification. But I can't have it manually from all the phone I'm testing. How is it theoritically done for distribution to send the notification to all the phone that installed the app?
You would usually store the device-token in a database on the backend-side once you receive it. When you want to send a notification to all devices, you fetch all the tokens from the database and send a message to each one.
Am working on an application in android that does the following. A part of the application is that the administrator can send universal notification to everyone registered to that application. I want this service to be in a way that the administrator uses his wireless to send the message to cellular gsm service. Now i was thinking it that is possible in android. How can i possibly do that?
A part of the application is that the administrator can send universal notification to everyone registered to that application. How can i possibly do that?
You can use Google Cloud Messaging for Android. It a service that allows you to send data from your server to your users' Android-powered device, and also to receive messages from devices on the same connection. You can send messages( or notifications) to all the Android users of your app. Each user would have a registrationId which would be unique for each user ( if you register them). That ID can be used to send messages to all your app users.
P.s: By wireless I am assuming internet.
Hi i want to use push notification on android device and get device location for more information
I want to write application for android that when server want to get android device location push a notification timely to the device and the application on the device send device location to server timely.
I can't use Cloud to device messaging service because this service need that user first online and after user is online send server notification with C2DM service!.But i want to send notification to device and get device location any time server wants.
For any sort of push notification to be made possible, your client will need to be online. An offline client cant accept push notifications until it is online.
A C2DM push can be initiated by the server. No need for client to start it. The server just needs to send a message to the C2DM server and notification will be sent.
What you basically need to do is, on receiving the notification from C2DM server, make your C2DM base receiver call a function, which retrieves the clients location data using LocationManager and send it to the server.
EDIT for MQTT:
i havent done this much myself but it can be used for push service
You need:
an MQTT broker which runs on the server side, like the mosquitto broker which is Open Source.
an MQTT client library which you include in your Android app, enabling your app to connect, subscribe, and publish messages. refer this http://mqtt.org/software
to come up with a way of uniquely identifying users or devices, and then use that as a topic so that you can individually publish a message to one device.