android - How do we send push notifications to thousands of devices (registration IDs) from PHP server -
We have installed GCM client and the functionality of sending push notifications by using PHP scripts works fine too. Now the next task is the Thousands registered devices in the Android app
What is the proper way to send push notifications to all these devices?
I am using PHP Web Server (HTTP). I hope my question is quite clear.
Work scripts in use to send push notifications
& lt ;? Php // Please enter api_key you get $ api_key = "fair-api-key" from Google console; $ Name = $ _POST ['name']; $ Deal = $ _POST ['deal']; $ Valid = $ _POST ['valid']; $ Address = $ _POST ['address']; // Please enter the registration ID of the device on which you want to send the message $ registration id = array ("some registration ID"); $ Message = array ("name" = & gt; $ name, "deal" => $ deal, "valid" = & gt; $ valid, "address" = & gt; $ address); $ Url = 'https://android.googleapis.com/gcm/send'; $ Fields = array ('registration_ids' = & gt; $ registration ID, 'data' = & gt; array ("message" => message $),); $ Header = array ('authorization: key =' .api_key, 'content-type: app / jason'); $ Ch = curl_init (); Curl_setopt ($ ch, CURLOPT_URL, $ url); Curl_setopt ($ ch, CURLOPT_POST, true); Curl_setopt ($ CH, CURLOPT_HTTPHEADER, $ headers); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ ch, CURLOPT_POSTFIELDS, json_encode ($ fields)); $ Result = curl_xac ($ CH); Curl_close ($ ch); $ Return result; ? & Gt;
I have found a link for official document.
This clearly explains the way to handle the above mentioned issue. So now the answer to this question is! :)
Send multicast messages efficiently One of the most useful features in GCM is the support for more than 1,000 recipients for a single message. This capability is your complete user base For example, suppose you had a message that needed to be sent to your 1,000,000 users, and your server could send around 500 messages per second The Son can afford to send. If you send each message with only one recipient, then it will take around 1,000,000 / 500 = 2,000 seconds or half an hour. However, attaching 1,000 recipients in each message, 1,000,000 / 1000/500 = 2 seconds is required to receive the total time required to send the message (1, 000, 000 / 1,000) This is not only useful, but timely data Important, such as natural disaster alerts or sports scores, where a 30 minute interval can provide useless information
Comments
Post a Comment