cron - Shedule Push Notification using gcm and php to 80k and above users -


first check database table finding unsent message has been posted different users. , if available following code , run using cron job every 5 min.

select * `jkeio_community_gcmusers`; //contain gcm users $i=0;  while($data_apps=mysql_fetch_array($data_app))          {  $message1=$i.'you have new item in akhbar';  sendnotificationandroid($data_apps['gcm_regid'],$message1); //send function sending push notification android , sends message via curl method $i++;               } 

after sending message i’ll set unsent flag sent using update query

all thing ok in concern 100 or 200 users when users increase messages delivering on time should can please suggest me how can achieve that

thanks in advance anand neema

gcm allows send notification 1000 device @ time, suggest refactoring method sendnotificationandroid accept array of gcm registration ids instead.

for example, first go through database rows , collect reg ids , append them array. once array size reaches 1000 (or no more reg ids add), pass new sendnotificationandroid method build notification payload this:

{   "registration_ids" : ["regid1", "regid2", "regid3", ....., "regid1000"],   "data" : {     ...   }, } 

so, 80k users, need 80 loops send notifications, , alma mundo suggested, better use curl_multi_exec send requests gcm server.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -