Search code examples
androidioscordovapush-notificationscheduling

Schedule Push Notifications


I need to send push notifications (PN) at some fixed time. For example, I don't want to wake my users before 8AM, so I would like to instruct google to deliver PNs at 9AM each day.

Problem is, my users might be spread all over the globe, I really cannot tell what locat time is there... does google give the ability to schedule PNs by local time of registered applications?

PS1: I read about iOS's UILocalNotification (maybe there is similar for Android too) but I don't want to set anything locally, I just want to send the PN from a remote server (with custom data) and put a restriction regarding the delivering time.

PS2: I am using Phonegap to develop the app and I am already able to send instant PNs to certain devices.


Solution

  • You can't instruct the push service (neither APNS nor GCM) when to deliver the notification. Both services try to deliver the notification as soon as possible (assuming the device is connected to the internet).

    The only exception to my previous statement is that in GCM you can use the delay_while_idle flag to prevent the notification from being sent while the device is idle. This would prevent delivery while your users are not using the device.

    If you want the notification to be delivered at a certain hour of day, and to consider the local time zone of the recipient device, you must manage it in your server. When your app sends the device token / registration ID to your server, you can send the local time zone of the device. Your server will know the time zone of each device, and send the notifications at the preferred hour.