I am using a custom php webserver for an im program to send push messages, for now i can send push notifications to mobile phone but i am not sure about how to use it properly.
By this i mean should i send all messages as push notifications, is it possible to do that? Is there any limitations about push notification's size? Or should i start a timer to check new messages after first notification and finish the timer when the activity is closed?
So what would be the most proper way to get instant messages from the server?
For Android the limitation on the push notification size is 4k. If your messages are smaller than that, you can use push notifications for sending all the content.
However, delivery of push notifications is not guaranteed, so it's a better practice to use if as a means for the server to notify the app that new data is available, especially when it's not running in the foreground. The app then calls the server to retrieve the data.
When the app is in the foreground, you can poll the server periodically for new data.
Related
I want to send a Push notification to different users at different time. The time will be devise time not server time.
For example -
I want to send a push notification to 'Ajay' at 8AM of device time - 'Good Morning Ajay'
I want to send a push notification to 'Gargee' at 2PM of device time - 'Have a wonderful day'
How do I receive the device time before sending the push notification?
You can't schedule notification on mobile side.
Notification messages don't execute your application code when your app is in the background. All messages sent from the Firebase console are Notification messages. So you can't currently use the Firebase console for what you are describing. So, you can send Data messages from your app server which can trigger background execution of code. You can manage the notification scheduling on your app server Using cronjob.
Otherwise, You can write cloud function for notification scheduling...
You can take the support of local notification here. You can either fire local notification or you can use DispatchQueue.main.asyncAfter to make an API call for saving the device time and also fire the push notification accordingly.
I am trying to figure out how Facebook / Twitter sends push notifications like "You have 20 new followers"I don't know how to call it but i want to learn the underlying algorithm of this in Android. Please help, Thanks !
On Android you can execute your code before actually showing a push notification. They could simply send a push notification to all devices with an identifier, then the app can make a request to the server and get the needed information in order to show the push notification.
They can also send one push notification per device, as they can associate the push notification key with the user login, and the server would fire a push notification every time there is an event that demands a push notification.
But there are also other ways of doing this, for example, they can, for example run locally in background and create a local notification when the app decides it is necessary.
I'm working on an app that is very simple (it's a chat app)
I have a server and Android users.
for example say we have 2 users, user_a and user_b.
user_a enters a chat room and sends "hi user_b" (user_b is registered to this chat room)
when user_a sends his message, it is also sent to the server.
I'd like to make a service that will be running always in the background even when the app isn't running. that service will check for new updates each time.
so I'd like user_b to receive the message, and it will appear as notification.
in order to do it my approach is to make a service that will continuesly run in the background. any suggestions?
The best way to do this is sending messages to your server, which will notify recipients via GCM in real-time. You need to create a gcm intent service so you can catch gcm messages and handle them properly in your app (build a notification and updating chat activity)
You can also broadcast the messages you receive from gcm notifications so you update your chat online (like all chat apps do…)
I recommend you to read about GCM and broadcast
While reading some article about push notifications, I got to know that push notifications will not be delivered 100% to the device.
In this case how can handle my application functionality in a better way ,
why I am asking is because in the push notification. I will be sending the last updated record id based on that I will be updating data /information in my device.
If I am not receiving any push notification then I have to manage this situation based on some time slot I have to keep on checking the server to fetch the record if i am doing in this way then it will affect for battery because keep on checking method whether some data as update or not
Which we will be the good way to handle this situation, I need a logic for better way of doing.
First of all - On contrary to documentation, Push Notification is working consistently for us.
Secondly, the way I would design this by keeping track of receipt of push notification. For instance:
Server Sent the Push payload to APNS and note down the time.
Client received the Push Notification and make a server call & inform the receipt of notification and pulls the record details.
If server did not receive a notification of push receipt within X period then trigger another push notification. OR
For any further service call, Server can also inform client of missed notification confirmation. Based on this client can trigger the server pull for that record. So, its not a timer based pull but a more informative decision based on data.
PS: From your description I believe you are sending push payload not exceeding 256 bytes.
(The following question is for mobile platforms in general (iPhone, Android, Blackberry))
We are integrating chat functionality into our existing application. I designed the system with a .Net web service and Sql Database to keep track of chat messages. Everything's working fine so far, when the chat window is open.
I need a way to notify the user of a new message when he/she is not currently viewing the chat screen (meaning either the app is not in the foreground or they are in another section of the app (not the chat screen).
Obviously, push notifications would be perfect here, but I'm not sure when I should be sending pushes.
How would the client sending the message know whether or not the other guy is viewing the chat screen? Should I just be sending pushed with every single message and have the receiving device decide whether or not it needs to pop up a window or display something in a nofication bar?
It seems like overkill to be pushing every single time a message is sent. How is this normally done?
Any ideas at all would be greatly appreciated.
Thanks.
First and foremost, keep in mind that your server will act as the broker for all messages passed between different chat clients. Here's how this could work:
User A initiates a message for user B
Message gets sent to the server.
Server determines that this message is for user B.
Server initiates a push notification and delivers the message to user B.
Now why would you need to push every single chat message? Because the only other way for your users to get notified would be to poll your server for new messages. Constant polling (at whatever rate you determine) is extremely bad in the mobile realm due to limited resources (battery, networking, etc.)
In a push notification scenario, it is up to your application to handle the logic of whether the user is notified on receiving a new message. What this means is that when user B receives a new message from user A, it's up to you to decide if you wish to notify B (i.e. bring your app to the foreground) or not. In either scenario, you want to use push notifications instead of polling.
On a similar note, user B does not necessarily have to know that user A's application (your app) is in the background which is why you will need to handle that logic (within your app) appropriately.
Push notification normally is applied to the application if it is not in the foreground. It is a way to wake-up the application to handle a new transaction from the server. Basically, a push notification is to be done if the client is running in the background and a new message is ready to be fetched from the server. As long as the new message is not fetched, if other messages arrive on the server, a push notification should be sent to the application.
Push notification is not necessary if the application is still running even if the user is viewing other screens of the application. It is however important that a thread is handling the connection to the server which is "patiently" waiting for transactions from the server.
One question, what protocol are you using for the messaging?.. Is it OMA IMPS protocol?