android - GCM PHP to send all devices -


i have problem gcm , need topic. send message mobile devices

php:

     $resultcoment = mysql_query("select * notificaciones");      while ($row = mysql_fetch_array($resultcoment)){     $result = '"' . $row['regid'] . '", ';     //print_r($result);     $registrationids = array($result);  }      $message = $_post['message'];      $fields = array(                 'registration_ids'  => $registrationids,                 'data'              => array( "message" => $message ),                 ); 

result:

 "apa91bhmihsncsg_yvhyzmprrxmw-e_iy7bpa9bo934n67afw8hxjhzvm1mnhrpartn6xbkxvjz9t9yfh9qni0zm5b9cpgxdhrkhystxyrwtrld02lq-   v_e4zwkigghqt4bph_zlnggaau6hwo8ny8mm2_d7glekwckkzdnhwfo5hxghwf4gbzm", "apa91bhmihsncsg_yvhyzmprrxmw-e_iy7bpa9bo934n67afw8hxjhzvm1mnhrpartn6xbkxvjz9t9yfh9qni0zm5b9cpgxdhrkhystxyrwtrld02lq-v_e4zwkigghqt4bph_zlnggaau6hwo8ny8mm2_d7glekwckkzdnhwfo5hxghwf4gbzm", "apa91belwwgutnoi3yrrunj_bbaacdc4pascb3lxcfwqm9ralqe0hc0c1xvf-eir7ilyflbemdjnmpy-503fqzopajjt514zo1j86uhuobhlu79pktvzjmxibavoiucasky__jvtbqalvmz8njtzzrg81tf1-svtjw", "apa91belwwgutnoi3yrrunj_bbaacdc4pascb3lxcfwqm9ralqe0hc0c1xvf-eir7ilyflbemdjnmpy-503fqzopajjt514zo1j86uhuobhlu79pktvzjmxibavoiucasky__jvtbqalvmz8njtzzrg81tf1-svtjw",       {"multicast_id":8410297698153738741,"success":0,"failure":1,"canonical_ids":0,"results":   [{"error":"invalidregistration"}]} 

what's problem?

you're overwriting array in each iteration. want push elements end of registrationids array. here's how:

$resultcoment = mysql_query("select * notificaciones"); $registrationids = array();  while ($row = mysql_fetch_array($resultcoment)){   $result = '"' . $row['regid'] . '", ';   //print_r($result);   $registrationids[] = $result; }  $message = $_post['message'];  $fields = array(             'registration_ids'  => $registrationids,             'data'              => array( "message" => $message ),             ); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -