0

When I get sendRequestToMembers request from the App, in server side, I've to send push notification to group of members in queue. For example for a group of 15, I've to send notifications to the first five, wait for 20 seconds, and if no member has accepted the request, send to the next five members. If anyone has accepted the request stop the loop and send a response to the app. Or at the end of the loop if no one accepted the request, send some other response to the app.

I'm using PHP. How can I wait for 20 seconds before checking for any accepted request?

If I use wait(20) the whole thread will stop responding, and request would time out. Cron is not useful for jobs less than a minute.

Any suggestion?

Hadi Sharghi
  • 903
  • 16
  • 33
  • You have to manipulate DOM and for do that you can not use PHP because is server side language. waith() method will stop the php execution. For DOM manipulation you have to use ajax by javascript. Google it, because is full of tutorial – Gabriele Carbonai Sep 15 '17 at 22:55
  • @GabrieleCarbonai Using Ajax needs a client side to view and load the script AFAIK. I don't have that. My client side is an iOS/Android App – Hadi Sharghi Sep 16 '17 at 05:59
  • if you make a mobile app, you don't need to find a solution in PHP but in swift for IOS and java for android... you have to call a web page through method every 20 seconds. Look here for example https://stackoverflow.com/questions/30090309/how-can-i-make-a-function-execute-every-second-in-swift – Gabriele Carbonai Sep 16 '17 at 11:48
  • @GabrieleCarbonai My server side programming language is PHP. I send push notifications in PHP via API. Everything was fine till the employer wants to send push notifications in queue not all at once. – Hadi Sharghi Sep 16 '17 at 11:58
  • ok but PHP don't do that, so if you want to call a server side every tot seconds you have to use javascript for the web or the relative language if you are in mobile, like swift... no other solution. In other words PHP not sending to your mobile but is your mobile that have to ask it to PHP – Gabriele Carbonai Sep 16 '17 at 12:01
  • @GabrieleCarbonai Yes, I think it's beyond PHP's features – Hadi Sharghi Sep 16 '17 at 12:03
  • you can call PHP once and not more... if you need push notification: https://www.appcoda.com/push-notification-ios/ – Gabriele Carbonai Sep 16 '17 at 12:06

0 Answers0