【问题标题】:can i send multiple messages to multiple devices at a time using GCM push plugin in php我可以使用 php 中的 GCM 推送插件一次向多个设备发送多条消息吗
【发布时间】:2014-09-19 07:38:20
【问题描述】:

如何一次向多个设备发送多条消息

$apiKey = "xxxxx";
$registrationIdArray = array('xxx_1','xxx_2'); 
$msg = array('message' => 'message_1','title'=> 'title_1','message' => 'message_2','title'=> 'title_2'); 
$pusher = new Pusher($apiKey); 
$pusher->notify($registrationIdArray, $msg);

【问题讨论】:

    标签: php android cordova push-notification google-cloud-messaging


    【解决方案1】:

    我已经编辑了我的代码,请使用这个

     <?php
     include_once './GCM.php';
    $regid = $_POST['regid'];//your registration id array 
    $fields1=$_POST['message'];//your message array
    $total_message = count($fields1);//count total no of message
    $total_records = count($regid);//Count total number of registration id
    for($j=0;$j< $total_message;$j++)//loop for sending multiple messgae
    {
    for($i=0;$i< $total_records;$i++)//loop for sending to multiple device
    {
        $registatoin_ids = array($regid[$i]);
        $message = array("price" => $total_message[$j]);
        $result = $gcm->send_notification($registatoin_ids, $message);
    }
    }
    ?>
    

    【讨论】:

    • 感谢您的友好回复.. 但我不想在这里向多个设备发送一条消息我想在向 gcm 服务器的单个请求中向多个设备发送多条消息.. 如果有有什么方法可以实现这一点,请帮助我
    猜你喜欢
    • 1970-01-01
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多