Is it possible to set up a Scheduled Push notification from the GCM server.
Example:
As I click a button i send an api call to the GCM server to send me a push after 30min.
Is that possible?
If yes, please guide me.
Thanks in advance.
No, it's not possible. GCM server attempts to deliver the messages you send to it immediately.
If you want to schedule a message for delivery at a given time, schedule it in your server. i.e. make your server send it to GCM server after 30 minutes.
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.
How can I send a push notification to my android phone with OneSignal
example I want to send automatic message at 6.00am everyday.
How can I implement it?
You can do it by running cron job on server side.
It's so simple : just set cron to start everyday on 6 am and run the command to send push notif message to all fcm_tokens which are registered already.
I suggest you to queue the messages for getting better result.
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.
How can I send heartbeat to the GCM server . So that we could keep the connection alive.
I used the below code to send heartbeat to the GCM server.
mContext.sendBroadcast(new Intent("com.google.android.intent.action.GTALK_HEARTBEAT"));
mContext.sendBroadcast(new Intent("com.google.android.intent.action.MCS_HEARTBEAT"));
But it again delayed the message.
After a long idle state I sent a notification to my app and gmail app.
The Gmail app receives the notification within time and my app not.
How it is happened. AFAIK The GCM uses port 5228 to receive messages. Then Why gmail received the message on time and my app received message after a long time.
What should I do to receive the messages on time.
Couple solutions that come in to mind:
Did you try to set delay_while_idle flag to false?
You can force android itself to send the heartbeat by broadcasting the following intents.
com.google.android.intent.action.MCS_HEARTBEAT
com.google.android.intent.action.GTALK_HEARTBEAT
Hope this works for you.
I have developed an app using GCM for push notification.My app using for stacking purpose so I have to receive notification like in First in First out order.But now am not getting notification from GCM in order.How to manage to receive notification in order and is possible to manage GCM server from our end.
No it's not possible in GCM server. But another way is you can Hack this Notification in your Server triggered by GCM and Run a cron at particular order.
no you cannot get the notification in first in first out order .they are randomly generated by the server.you can do this in your server connected with GCM and put them in serial order
gcm document already mention this
http://developer.android.com/google/gcm/adv.html
Note that the order of delivery is not guaranteed.
GCM order of message is not guaranteed. For this you can achieve another way.
Ask to server guys to create API(Webserver) for message, The message is same as they were earlier sending through the GCM.
After that you have to create Calender scheduler (Like Every 5 min) and then call this web-service and show notification.