简体   繁体   中英

send Massive push notification to GCM

I have to send Push Notifications with different messages for large number of devices(More than 10k devices per day).But sometimes its not receiving all of the devices.I set up a function pushNotificationToUsers($heading,$message,$registraionids) to send the push notification and I am not sure about my method is correct ,if i am wrong please correct me.

function  pushNotificationToUsers($heading,$message,$registraionids){
        //array of registration ids in $registraionids         
        $key="xxxxxxxxxxx";
        // Set POST variables
        $url = 'https://android.googleapis.com/gcm/send';
        $fields = array(
                        'registration_ids'  =>,$registraionids,
                        'data'              => array( "message" => $message,"title"=>$heading,"soundname"=>"beep.wav" ),
                        );
        $headers = array(
                            'Authorization: key=' . $key,
                            'Content-Type: application/json'
                        );
        // Open connection
        $ch = curl_init();
        // Set the url, number of POST vars, POST data
        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 ) );
        // Execute post
        $result = curl_exec($ch);
        // Close connection
        curl_close($ch);

        }

I'm using php in my serverside

For Android,

The message size limit in GCM is 4 kbytes.

https://developer.android.com/google/gcm/server.html#params

The message size limit in C2DM is 1024 bytes. (DEPRECATED)

https://developers.google.com/android/c2dm/#limitations

For iOS,

in iOS the size limit is 256 bytes, but since the introduction of iOS 8 has changed to 2kb!

https://forums.aws.amazon.com/ann.jspa?annID=2626

Also, see below stuffs

After Google replaced C2DM with GCM, they took off all limits.

http://developer.android.com/google/gcm/c2dm.html#history

The only limits you run into the GCM documentation is this:

http://developer.android.com/google/gcm/adv.html#lifetime

I think this answer is enough clear for your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM